Fetching contributors…
Cannot retrieve contributors at this time
235 lines (154 sloc) 5.12 KB


Onion, The fast approach to make/install/bundle PEAR packages for PHP.

Onion is able to generate a PEAR2-compatible package.xml file from a very simple config file, you can release your PEAR package very quickly!

And through Onion, you can also install PEAR dependencies into local bundle (just like Ruby Bundler).

Onion is not target to replace other package manager, its target is to make current PEAR ecosystem easier.

Let's keep hard long PEAR package.xml away! :-)

Onion is for people want to..

  • Build PEAR package easily, quickly.
  • Install PEAR dependencies into local project directory. (like Ruby Bundler)

What People Say


its own package.ini file looks simple enough to edit and maintain.

It's been super-easy to get up and running and I haven't encountered any real
problems.  Onion looks good already.  



  • PHP 5.3
  • simplexml extension
  • DOMDocument extension
  • curl

The minimal spec file

name = Onion
desc = package description
version = 0.0.1
author = Yo-An Lin <>
channel =

A Quick tutorial for building PEAR package

Get and install onion:

$ curl -s | sh

Please make sure your directory structure:

src/   # contains php source code
doc/   # documentation files (optional)
tests/ # unit testing files

Fill your package.ini file:

name = Onion
desc = package description
version = 0.0.1
channel =
author = Yo-An Lin <>

To generate a package.xml 2.0 spec file for PEAR and build a PEAR package, just run:

$ onion build --pear

Then Your PEAR package is out!

The --pear flag is optional.


$ onion help build

Adding package dependencies

name = Onion
desc = package description
version = 0.0.1
author = Yo-An Lin <>
channel =

php = 5.3
pearinstaller = 1.4 = 0.0.1


Install PEAR dependencies into vendor/ directory

$ onion install

Compile package to Phar executable/library file

An example, we use onion to compile our executable file onion:

$ onion compile \
    --executable \
    --classloader \
    --bootstrap scripts/onion.embed \
    --lib src \
    --lib ../CLIFramework/src \
    --lib ../GetOptionKit/src \
    --output onion

Available Config Tags

please checkout doc/

Version Naming

version naming standard from PEAR group:

Customize roles

There are many built-in roles so that you don't need to define it by yourself, built-in roles are:

  • src/ php role
  • docs/ doc role
  • tests/ test role
  • *.md doc role

But you can add custom roles by yourself.

path/to/data = data
path/to/library = php
path/to/doc = doc

A more detailed example

name        = your package name
desc        = package description
summary     = ....                  # optional, default to Description
homepage    =   # optional
license     = PHP                   # optional, default to PHP
version     = 0.0.1
version.api = 0.0.1                 # optional, default to "version"
channel     =          # default

; lead developer
author         = Yo-An Lin <>

; other authors
authors[]      = Yo-An Lin <>
authors[]      = Yo-An Lin

 ; contributors ...
contributors[] = ...                # optional
maintainers[]  = ...                # optional

php = '> 5.3'
pearinstaller = '1.4.1'

; pear package based on channel = 1.1

; pear package based on URI
package =
package = conflicts

extension/reflection = 
extension/ctype = 
extension/pcre = 


; mapping files to role
your_script = bin

; glob is supported.
*.md = doc
*.php = php

[optional remoteshell]
hint = Add support for Remote Shell Operations
channel/test = 0.1
channel/foo = 0.2
extensions[] = ssh2


Make a fork from Onion and clone it:

$ git clone
$ cd Onion

Run onion to install dependencies

$ bin/onion install

To run unit tests:

$ phpunit

To test onion command:

$ scripts/onion help

To compile onion:

$ scripts/

PEAR Features not support yet

Current install command does not support PEAR special features like:

  • PEAR Task: like replace content, rename ... etc
  • PECL installation


If you have questions about Onion or want to help out, come and join us in the #onion-dev channel on