ZenMagick 0.9.8


org.zenmagick.core.utils.ZMPhpCompressor
\core\utils\ZMPhpCompressor.php at line 52

Class ZMPhpCompressor

ZMPhpCompressor

public class ZMPhpCompressor

Generic PHP code compressor.

Can be used to compress all PHP files of a given folder or folder tree into a single PHP file.

Supports some archaic form of inheritance/dependencies in that levels are processed one after the other. That means that a class in a second level folder may extend any class that resides in the root folder or any first level folder.

If no temp folder is configured, the location of this file will be used to store temporary files and folders.

Author:
DerManoMann
Version:
$Id: ZMPhpCompressor.php 2793 2009-12-29 09:45:11Z dermanomann $

Field Summary
protected mixed

$errors_

protected mixed

$flatFolder_

protected mixed

$outputFilename_

protected mixed

$rootFolders_

protected mixed

$stripCode_

protected mixed

$strippedFolder_

protected mixed

$tempFolder_

Constructor Summary

ZMPhpCompressor(mixed root, string out, string temp)

Create new instance.

Method Summary
void

clean()

Clean up all temp.

boolean

compress()

Compress accoding to the current settings.

protected void

compressToSingleFile(string in, string outfile)

Compress all files into a single file

protected array

finaliseFiles(array files)

Empty callback to make final adjustments to the file list before compressing to a single file.

protected void

flattenDirStructure(string in, string out)

Flatten the directory structure.

array

getErrors()

Get errors.

boolean

hasErrors()

Check for errors.

void

setOut(string out)

Set the output filename.

void

setRoot(mixed root)

Set the root folder(s).

void

setStripCode(boolean strip)

Configure whether or not to strip the compressed code.

void

setTemp(string temp)

Set the temp folder.

protected void

stripPhpDir(string in, string out, boolean recursive)

Recursivley strip a directory.

protected void

stripPhpFile(string in, string out)

Strip a PHP file.

protected string

stripPhpSource(string source)

Strip the given PHP source text.

Field Detail

\core\utils\ZMPhpCompressor.php at line 56

errors_

protected mixed $errors_

\core\utils\ZMPhpCompressor.php at line 60

flatFolder_

protected mixed $flatFolder_

\core\utils\ZMPhpCompressor.php at line 54

outputFilename_

protected mixed $outputFilename_

\core\utils\ZMPhpCompressor.php at line 53

rootFolders_

protected mixed $rootFolders_

\core\utils\ZMPhpCompressor.php at line 63

stripCode_

protected mixed $stripCode_

\core\utils\ZMPhpCompressor.php at line 59

strippedFolder_

protected mixed $strippedFolder_

\core\utils\ZMPhpCompressor.php at line 55

tempFolder_

protected mixed $tempFolder_

Constructor Detail

\core\utils\ZMPhpCompressor.php at line 73

ZMPhpCompressor

public ZMPhpCompressor(mixed root, string out, string temp)

Create new instance.

Parameters:
root - The root directory to compress (or array of directory names); default is null.
out - The [full] output filename; default is null.
temp - A temp folder for transient files and folders; default is null.

Method Detail

\core\utils\ZMPhpCompressor.php at line 157

clean

public void clean()

Clean up all temp. files.


\core\utils\ZMPhpCompressor.php at line 167

compress

public boolean compress()

Compress accoding to the current settings.

Returns:
true if successful, false on failure.

\core\utils\ZMPhpCompressor.php at line 403

compressToSingleFile

protected void compressToSingleFile(string in, string outfile)

Compress all files into a single file

Parameters:
in - The input directory.
outfile - The output file.

\core\utils\ZMPhpCompressor.php at line 393

finaliseFiles

protected array finaliseFiles(array files)

Empty callback to make final adjustments to the file list before compressing to a single file.

Parameters:
files - List of files.
Returns:
The final list.

\core\utils\ZMPhpCompressor.php at line 326

flattenDirStructure

protected void flattenDirStructure(string in, string out)

Flatten the directory structure.

Parameters:
in - The input directory.
out - The output directory.

\core\utils\ZMPhpCompressor.php at line 88

getErrors

public array getErrors()

Get errors.

Returns:
List of text messages.

\core\utils\ZMPhpCompressor.php at line 97

hasErrors

public boolean hasErrors()

Check for errors.

Returns:
true if errors exist.

\core\utils\ZMPhpCompressor.php at line 119

setOut

public void setOut(string out)

Set the output filename.

Parameters:
out - The [full] output filename.

\core\utils\ZMPhpCompressor.php at line 106

setRoot

public void setRoot(mixed root)

Set the root folder(s).

Parameters:
root - The root directory to compress (or array of directory names); default is null.

\core\utils\ZMPhpCompressor.php at line 150

setStripCode

public void setStripCode(boolean strip)

Configure whether or not to strip the compressed code.

Disabling stripping will have the following effects:

Parameters:
strip - The new value.

\core\utils\ZMPhpCompressor.php at line 128

setTemp

public void setTemp(string temp)

Set the temp folder.

Parameters:
temp - A temp folder for transient files and folders (unless stripping is off).

\core\utils\ZMPhpCompressor.php at line 287

stripPhpDir

protected void stripPhpDir(string in, string out, boolean recursive)

Recursivley strip a directory.

Uses ZMLoader::findIncludes() to find files to process.

Parameters:
in - The input directory.
out - The output directory.
recursive - If true, strip recursivley.

\core\utils\ZMPhpCompressor.php at line 254

stripPhpFile

protected void stripPhpFile(string in, string out)

Strip a PHP file.

Parameters:
in - The input filename.
out - The output filename; if null just echo; default is null.

\core\utils\ZMPhpCompressor.php at line 205

stripPhpSource

protected string stripPhpSource(string source)

Strip the given PHP source text.

Parameters:
source - The PHP source code.
Returns:
The stripped code.

ZenMagick 0.9.8