Phark is a package management system for PHP code. It provides dependencies, versioning and installation for packages either system-wide or for an individual project.
Note: Phark is still in active development, don't install it yet! Read the STATUS document for more details
$ curl http://pharkphp.org/install | sh
Phark packages can be installed manually with the command-line tool, phark.
$ cd projects/myproject $ phark install pheasant
You can then proceed to reference that code in your application.
<?php require_once 'pheasant/Pheasant.php';
Declaring dependencies in a project
A project can declare the packages it depends on with a
Pharkdeps in the top
level of the project:
<?php $deps ->dependency( 'pheasant', array('git'=>'https://firstname.lastname@example.org/lox/pheasant.git') ) ->dependency( 'yaml', '~>1.0.0' ) ->dependency( 'simpletest', '2.0.0beta1', array('group'=>'dev') ) ;
Then the following should be executed at the top level of the project:
$ phark deps $ phark lock-deps
This will result in the above dependencies installed, and a
generated with the exact versions installed. This can be committed to your SCM
to make sure other contributors get the same dependency versions.
How does Phark work?
Unfortunately, a little bit of magic is required. PHP include and require work relative to PHP's include_path. In other languages it's possible to influence this via environmental variables, but in PHP it's either set via Apache or via php.ini.
See alternate installation methods if you use this directive for something else.
What do the Packages look like?
Check out the wiki page on the anatomy of a phark package.
Why the name?
Phark was born out of my frustration with trying to write and distribute re-usable code in PHP. Phark packages use the PHP Archive format, Phar.
Read the original proposal on github.
Why not PEAR?
PEAR is a complicated beast, with a lot of legacy. Aside from the rough port to PHP5.3 and bulky codebase, PEAR still doesn't allow for multiple versions of a package to be installed side-by-side, or for per-project installations.
What's worse is how hard it is to contribute a PEAR package. Phark allows anyone to submit packages for instant consumption by other developers. If you really want you can even consume PEAR packages via this mechanism.
References and Reading
Lots of other languages have great package management tools. Any great software is built on the shoulders of giants, in Pharks case, that would be the following:
- RubyGems (ruby)
- Bundler (ruby)
- RIP (ruby)
- PIP (python)
- VirtualEnv (python)
- NPM (nodejs)
- Homebrew (ruby)
Some notes on each of these are available on the wiki.