Forum Support/help Bug tracker

The PHP tool to play with phar

DOWNLOAD NOW

Stable: 1.0.0

Empir is a simple and robust php script that let's you build a phar from an entire PHP application but also extract and convert phar files. The phar extension provides a way to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation. See PHP Phar documentation

Empir consists of just one file, a command line tool, written in PHP, working on Unix and Windows. There are no external dependencies, no need for a database, no need to setup credentials, and nothing needed to be installed or configured.
The only thing that Empir requires is PHP >= 5.3.0

Installation

Direct installation

Installing Empir is as simple as downloading the latest stable empir file and saving it where you see fit. Extract it and check that Empir works correctly by calling it without any argument:
$ php empir
You should see the Empir help.

PEAR installation

$ pear channel-discover empir.sourceforge.net/pear
$ pear install empir/empir
Check that Empir works correctly by calling it without any argument:
$ empir
You should see the Empir help.

Features

Besides its size and simplicity, Empir is packed with a lot of features:

Usage

Make a phar

Basic usage

$ php empir make <phar_file> <stub_file> <root_app> [options]
To make a phar with empir the setting phar.readonly must be set to 0 in your php.ini, otherwise you should use Empir like the following:
$ php -dphar.readonly=0 empir make <phar_file> <stub_file> <root_app> [options]

If you use Empir from PEAR installation don't care about this php option. It used directly in the executable file.

Let's explain the differents parameters:

Exclude files from your app

Use the option --exclude=PATTERN or --fexclude=FILE
$ php empir make <phar_file> <stub_file> <root_app> --exclude=".hg/*|*.txt" --fexclude="./excluding-list.txt"
These options are used to exclude files from the phar. "exclude" works with string, one or several patterns separate with a pipe. "fexclude" do the same thing but takes a file where are listed the patterns. One per line.
The example above excludes all files from the .hg/ directory, all text files and all the files matche patterns of excluding-list.txt of your entire application.

Format and compression

A phar can be one of these 3 formats: phar, zip and tar. Keep in mind that zip or tar phar can't be used whitout php extension phar activated. So for a best portability don't use format option. The same for compression, users of your phar will have the correct php extension (zlib or bzip2) to run it.

Use --format=FORMAT and --compress=TYPE

$ php empir make <phar_file> <stub_file> <root_app> --format=tar --compress=gz
These 2 options are independent from each other. The example above creates a compressed tar phar, my.phar.tar.gz
FORMAT: tar or zip
TYPE: gz or bz2

! Unfortunately zip compression is not supported !

Extract a phar

Extract a phar file (compressed or not) as a vulgar archive:
$ php empir extract <phar_file> [extract_path]
Extract all type of archive and compression supported by the `make` command.

See the parameters:

Convert a phar

This command allows to convert, compress or decrompress a phar file.
$ php empir convert <phar_file> <format> [compression]

Let's explain the differents parameters:

! Unfortunately zip compression is not supported !

Credits

Empir is brought to you by Jeremy Perret <j.perret.27@gmail.com>. Documentation design inspired by pirum. Empir is released under The MIT License.