项目作者: phpbrew

项目描述 :
Onion, The fast approach to build/bundle PEAR/PECL packages for PHP.
高级语言: PHP
项目地址: git://github.com/phpbrew/Onion.git
创建时间: 2011-11-20T15:18:09Z
项目社区:https://github.com/phpbrew/Onion

开源协议:GNU General Public License v2.0

下载


Onion

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! :-)

Build Status

Onion is for people want to..

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

What People Say

nrk:

  1. its own package.ini file looks simple enough to edit and maintain.
  2. It's been super-easy to get up and running and I haven't encountered any real
  3. problems. Onion looks good already.

2011-12-18 https://github.com/nrk/predis/commit/104cd1eae7f3fb2bff3ccd3193c3e31b8502af56

Requirement

  • PHP 5.3
  • simplexml extension
  • DOMDocument extension
  • curl

The minimal spec file

  1. [package]
  2. name = Onion
  3. desc = package description
  4. version = 0.0.1
  5. author = Yo-An Lin <cornelius.howl@gmail.com>
  6. channel = pear.php.net

A Quick tutorial for building PEAR package

Get and install onion:

  1. $ curl -s http://install.onionphp.org/ | sh

Please make sure your directory structure:

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

Fill your package.ini file:

  1. [package]
  2. name = Onion
  3. desc = package description
  4. version = 0.0.1
  5. channel = pear.php.net
  6. author = Yo-An Lin <cornelius.howl@gmail.com>

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

  1. $ onion build --pear

Then Your PEAR package is out!

The --pear flag is optional.

See:

  1. $ onion help build

Adding package dependencies

  1. [package]
  2. name = Onion
  3. desc = package description
  4. version = 0.0.1
  5. author = Yo-An Lin <cornelius.howl@gmail.com>
  6. channel = pear.php.net
  7. [require]
  8. php = 5.3
  9. pearinstaller = 1.4
  10. pear.php.net/PackageName = 0.0.1

Bundle

Install PEAR dependencies into vendor/ directory

  1. $ onion install

Compile package to Phar executable/library file

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

  1. $ onion compile \
  2. --executable \
  3. --classloader \
  4. --bootstrap scripts/onion.embed \
  5. --lib src \
  6. --lib ../CLIFramework/src \
  7. --lib ../GetOptionKit/src \
  8. --output onion

For C Extensions

Simple put a extension attribute:

  1. [package]
  2. ...
  3. extension = yourext

Available Config Tags

please checkout doc/SPEC.md

Version Naming

version naming standard from PEAR group: http://pear.php.net/manual/en/rfc.version-naming.standard.php

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.

  1. [roles]
  2. path/to/data = data
  3. path/to/library = php
  4. path/to/doc = doc

A more detailed example

  1. [package]
  2. name = your package name
  3. desc = package description
  4. summary = .... # optional, default to Description
  5. homepage = http://your.web.com # optional
  6. license = PHP # optional, default to PHP
  7. version = 0.0.1
  8. version.api = 0.0.1 # optional, default to "version"
  9. channel = pear.php.net # default
  10. ; lead developer
  11. author = Yo-An Lin <cornelius.howl@gmail.com>
  12. ; other authors
  13. authors[] = Yo-An Lin <cornelius.howl@gmail.com>
  14. authors[] = Yo-An Lin
  15. ; contributors ...
  16. contributors[] = ... # optional
  17. maintainers[] = ... # optional
  18. [require]
  19. php = '> 5.3'
  20. pearinstaller = '1.4.1'
  21. ; pear package based on channel
  22. pear.channel.net/package = 1.1
  23. ; pear package based on URI
  24. package = http://www.example.com/Foo-1.3.0
  25. package = conflicts
  26. extension/reflection =
  27. extension/ctype =
  28. extension/pcre =
  29. [roles]
  30. ; mapping files to role
  31. your_script = bin
  32. ; glob is supported.
  33. *.md = doc
  34. *.php = php
  35. [optional remoteshell]
  36. hint = Add support for Remote Shell Operations
  37. channel/test = 0.1
  38. channel/foo = 0.2
  39. extensions[] = ssh2

Hacking

Make a fork from Onion and clone it:

  1. $ git clone git@github.com:c9s/Onion.git
  2. $ cd Onion

Run onion to install dependencies

  1. $ ./onion install

To run unit tests:

  1. $ phpunit

To test onion command:

  1. $ scripts/onion help

To compile onion:

  1. $ scripts/compile.sh

PEAR Features not support yet

Current install command does not support PEAR special features like:

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

Community

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