Benjamin Billet

◈ Ingénieur de recherche et développement, docteur en informatique


Dernière màj: 18/02/2014

PHPackman (pronounce pacman) is a very simpe library for packaging a PHP application into a single self-extracting PHP file.

The generated archives are PHP files that contains multiple files (compressed or juste base64-encoded) and the code required for rebuilding the hierarchy of files.
The archive is perfectly autonomous, the PHPackman library is only required to build the archive.

Note: Compression requires the ZipArchive class (PHP 5 >= 5.2.0).

// prepare a compressed archive which will be deployed into a folder called "output_folder"
// at the end of the extraction, the browser will be redirected to "after_install.php"
$phpackman = phpackman_create('output_folder', true, 'after_install.php', '0777');

// add files and folders
phpackman_add_file($phpackman, 'aFile');
phpackman_add_file($phpackman, 'aFile', 'aVirtualFolder/aFile');
phpackman_add_folder($phpackman, 'aFolder');
phpackman_add_folder($phpackman, 'aFolder', 'anotherVirtualFolder');

// build the archive and write the content into "archive_name.pack.php"
phpackman_build($phpackman, 'archive_name.pack.php');

Note: For OOP addicts, a wrapper is provided with the library. See the source code for more information.

The source code is available on BitBucket under the licence Creative Commons Attribution 4.0 International (CC BY 4.0) :