note 102559 added to phar.compress

[email protected] Mon, 21 Feb 2011 11:50:48 -0800
Newsgroups php.notes
Message-ID <[email protected]>
For those who want the benefit of having a small compressed PHAR archive but don’t want to suffer the performance loss, use php_strip_whitespace when adding files to the archive. If your code has plenty of whitespace, docbocks, and single-line comments this function can greatly decrease archive size without the performance loss. 

<?php
$sDir = 'application';
$oPhar = new Phar ('app.phar');

$oDir = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($sDir), RecursiveIteratorIterator::SELF_FIRST);

foreach ($oDir as $sFile) {
	if ( preg_match ('/\\.php$/i', $sFile) ) {
		$oPhar->addFromString (substr ($sFile, strlen ($sDir) + 1), php_strip_whitespace ($sFile));
	}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 74.216.55.130
----
Manual Page -- http://www.php.net/manual/en/phar.compress.php
Edit        -- https://master.php.net/note/edit/102559
Del: integrated  -- https://master.php.net/note/delete/102559/integrated
Del: useless     -- https://master.php.net/note/delete/102559/useless
Del: bad code    -- https://master.php.net/note/delete/102559/bad+code
Del: spam        -- https://master.php.net/note/delete/102559/spam
Del: non-english -- https://master.php.net/note/delete/102559/non-english
Del: in docs     -- https://master.php.net/note/delete/102559/in+docs
Del: other reasons-- https://master.php.net/note/delete/102559
Reject      -- https://master.php.net/note/reject/102559
Search      -- https://master.php.net/manage/user-notes.php