librelist archives

« back to archive

Announce - Phar as distribution mode for the Photon particles and projects

Announce - Phar as distribution mode for the Photon particles and projects

Loic d'Anterroches
2011-03-25 @ 13:20

this is more a formal announcement with respect to what I wrote in my
previous roadmap email.

Basically, I have decided to go the Phar way and to do it fully. PHAR ==
(PH)p (AR)chive it is what jar is for Java or xpi for Firefox.

Like for both of them, you will be able to extract the full content of a
.phar file, so, this is not a way to obfuscate your code, but a way to
distribute it.

Photon itself will still be available as a PEAR package for the
developers of a project. But for the end users, suppose you create a
"fastblog" project, you will simply deliver it as one file "fastblog.phar".

The installation of fastblog for your end users will be as simple as:

$ scp fastblog.phar server:/home/deployment/fastblog.phar
$ ssh server
$ cd /home/deployment/
$ php fastblog.phar makeconf
$ vi config.php
$ php fastblog.phar server start

the creation/edition of the config file will not be needed when
updating. fastblog.phar will itself include Photon and all the non
PECL/PEAR dependencies of the software.

As a developer, when creating a new project, you will be able to
download particles (the Photon components/add-ons) from
directly with hnu:

$ hnu init myproject && cd myproject
$ hnu install mongodb_user
$ hnu install ceondo_search
$ hnu install simpleblog

this will install the 3 apps: mongodb_user, ceondo_search, simpleblog in
your project. They will be downloaded as .phar and extracted in your

Then you hack and you are happy, you want to make your project available
to some friends:

$ hnu project package fastblog

It will create a fastblog.phar based on the current project without
including the config.php file. If you want to bundle a config file
directly into the .phar for deployment:

$ hnu project package fastblog --include-conf=your/prod/config.php

The non inclusion of the config file by default is to avoid the "oups I
bundled all my private creditentials by mistake" kind of error.

Suppose you have created in your big project a small app/component you
want to share as a particle:

$ hnu publish myparticle

It will use a manifest file to collect, name, author, email, version,
etc. make the .phar, sign it, and push it online on We
will need to figure out the rights management with login/password or api
key, but the goal is that you can publish a component with a single
command. All the meta data of your particle can be included in the .phar
as the Phar archive support meta data.

The good point of a .phar distribution is that it is fully PHP
compatible in the sense that your component could be directly reused in
another project, for example a Zend project by just doing:

 <?php include 'myparticle.phar'; ?>

This means that if your particle is just delivering library stuff but
nothing specific to Photon like an application with views etc. you will
be able to reuse the .phar everywhere as they will not include all the
Photon machinery.

Of course, your feedback is welcomed,

Indefero - Project management and code hosting -
Photon - High Performance PHP Framework -
Céondo Ltd - Web + Science = Fun -