waltertamboer/pharcompiler

A PHAR compiler for PHP.

Maintainers

Package info

github.com/waltertamboer/pharcompiler

Homepage

pkg:composer/waltertamboer/pharcompiler

Statistics

Installs: 13

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

dev-master 2013-12-11 19:47 UTC

This package is auto-updated.

Last update: 2026-03-03 20:39:17 UTC


README

Build Status

PharCompiler is a compiler to easily create PHAR files. The concept is that you create a new instance of the compiler to which you give the name of the PHAR file. Next you add the files that should be packed into the archive and last you call compile.

Compiling

Compiling a .phar file is easy.

<?php

// build.php:
$compiler = new \WT\PharCompiler\Compiler('my.phar');
$compiler->setVariable('package_version', '1.0.0');
$compiler->addFile(__DIR__ . '/src/test.php');
$compiler->compile();

By using addFile and addDirectory you can add a list of files to the archive.

Meta Data Variables

It's possible to add meta data to the compiler. This meta data is injected in the source files. For example:

<?php

// build.php:
$compiler = new \WT\PharCompiler\Compiler();
$compiler->setVariable('package_version', '1.0.0');
$compiler->addFile(__DIR__ . '/src/test.php');
$compiler->compile();
<?php

// test.php:

echo 'Version: @package_version@';