Skip to content

Making PHPWee RC4-compatible #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@
"license": "BSD",
"homepage": "http://searchturbine.com/php/phpwee",
"authors": [
{
"name": "Search Turbine - Open Source PHP Dev Team",
"email": "community@searchturbine.com",
"homepage": "http://searchturbine.com",
"role": "Developer"
}
],
{
"name": "Search Turbine - Open Source PHP Dev Team",
"email": "community@searchturbine.com",
"homepage": "http://searchturbine.com",
"role": "Developer"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/searchturbine/phpwee-php-minifier"
}
],
"autoload": {
"files": ["phpwee.php"]
},
{
"type": "vcs",
"url": "https://github.com/searchturbine/phpwee-php-minifier"
}
],
"autoload": {
"psr-4": {
"PHPWee\\": "src/PHPWee"
}
},
"require": {
"php": ">=5.3.0"
}
}
}
52 changes: 40 additions & 12 deletions examples/example.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?
require_once ("../phpwee.php");
<?php
function myAutoloader($class)
{
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
include __DIR__.'/../src/'.$class.'.php';
}

spl_autoload_register('myAutoloader');

$html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29");
$minified = PHPWee\Minify::html($html);
echo print_performance_graph("Wikipedia",$minified,$html);
$minified = PHPWee\PHPWee::html($html);
print_performance_graph("Wikipedia", $minified, $html);

/*
$html = file_get_contents("http://www.codeproject.com/Articles/759094/Step-by-Step-PHP-Tutorials-for-Beginners-Creating");
Expand All @@ -28,11 +34,33 @@


///////////////////////////////////////////////////////////////


function print_performance_graph($subject,$minified,$html){
$before = strlen(gzcompress($html));
$after = strlen(gzcompress($minified));
$improvement = 100 * (1-($after/$before));
echo "<table style='width:100%; border:1px solid grey;text-align:center'><tr><th colspan=3><b>$subject</th><tr><th>Gzipped Bytes Before PHPWee</th><th>Gzipped Bytes After PHPWee</th><th>% Performance Boost</th></tr><tr><td>$before before</td><td>$after after</td><td> $improvement % faster </td></table><br><br>";
}

/**
* @param $subject
* @param $minified
* @param $html
*/
function print_performance_graph($subject, $minified, $html)
{
$before = strlen(gzcompress($html));
$after = strlen(gzcompress($minified));
$improvement = 100 * (1-($after/$before));
?>
<table style="width:100%; border:1px solid grey;text-align:center">
<tr>
<th colspan="3"><?= $subject; ?></th>
</tr>
<tr>
<th>Gzipped Bytes Before PHPWee</th>
<th>Gzipped Bytes After PHPWee</th>
<th>% Performance Boost</th>
</tr>
<tr>
<td><?= $before; ?> before</td>
<td><?= $after; ?> after</td>
<td><?= $improvement; ?> % faster</td>
</tr>
</table>
<br><br>
<?php
}
35 changes: 0 additions & 35 deletions phpwee.php

This file was deleted.

Loading