Skip to content
This repository

A [defunct] package manager for PHP 5.3.1+, inspired by rubygems, bundler and npm.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 man
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Makefile
Octocat-spinner-32 Pharkspec
Octocat-spinner-32 README.md
Octocat-spinner-32 STATUS.md
Octocat-spinner-32 phark.php
README.md

Phark

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 no longer under active development, I'd recommend Composer

Read the STATUS document for more details

Installing Phark

$ curl http://pharkphp.org/install | sh

Using Phark

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://lox@github.com/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 Pharkdeps.lock file 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.

To work around this, Phark uses the auto_prepend_file directive in php.ini. Each time a php script is run, the Phark stub is executed first to set up the include_path environment.

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:

Some notes on each of these are available on the wiki.

Something went wrong with that request. Please try again.