|
| 1 | +Onion |
| 2 | +===== |
| 3 | + |
| 4 | +Onion, The fast approach to make/install/bundle PEAR packages for PHP. |
| 5 | + |
| 6 | +Onion is able to generate a PEAR2-compatible package.xml file from a very simple config |
| 7 | +file, you can release your PEAR package very quickly! |
| 8 | + |
| 9 | +And through Onion, you can also install PEAR dependencies into local bundle (just like Ruby Bundler). |
| 10 | + |
| 11 | +Onion is not target to replace other package manager, its target is to make current PEAR ecosystem easier. |
| 12 | + |
| 13 | +Let's keep hard long PEAR package.xml away! :-) |
| 14 | + |
| 15 | +<!-- |
| 16 | +[](http://travis-ci.org/c9s/Onion) |
| 17 | +--> |
| 18 | + |
| 19 | +## Onion is for people want to.. |
| 20 | + |
| 21 | +* Build PEAR package easily, quickly. |
| 22 | +* Install PEAR dependencies into local project directory. (like Ruby Bundler) |
| 23 | + |
| 24 | +## What People Say |
| 25 | + |
| 26 | +nrk: |
| 27 | + |
| 28 | + its own package.ini file looks simple enough to edit and maintain. |
| 29 | + |
| 30 | + It's been super-easy to get up and running and I haven't encountered any real |
| 31 | + problems. Onion looks good already. |
| 32 | + |
| 33 | +2011-12-18 <https://github.com/nrk/predis/commit/104cd1eae7f3fb2bff3ccd3193c3e31b8502af56> |
| 34 | + |
| 35 | +## Requirement |
| 36 | + |
| 37 | +* PHP 5.3 |
| 38 | +* simplexml extension |
| 39 | +* DOMDocument extension |
| 40 | +* curl |
| 41 | + |
| 42 | +## The minimal spec file |
| 43 | + |
| 44 | +```ini |
| 45 | +[package] |
| 46 | +name = Onion |
| 47 | +desc = package description |
| 48 | +version = 0.0.1 |
| 49 | +author = Yo-An Lin < [email protected]> |
| 50 | +channel = pear.php.net |
| 51 | +``` |
| 52 | + |
| 53 | +## A Quick tutorial for building PEAR package |
| 54 | + |
| 55 | +Get and install onion: |
| 56 | + |
| 57 | + $ curl -s http://install.onionphp.org/ | sh |
| 58 | + |
| 59 | +Please make sure your directory structure: |
| 60 | + |
| 61 | + src/ # contains php source code |
| 62 | + doc/ # documentation files (optional) |
| 63 | + tests/ # unit testing files |
| 64 | + |
| 65 | +Fill your `package.ini` file: |
| 66 | + |
| 67 | + [package] |
| 68 | + name = Onion |
| 69 | + desc = package description |
| 70 | + version = 0.0.1 |
| 71 | + channel = pear.php.net |
| 72 | + author = Yo-An Lin <[email protected]> |
| 73 | + |
| 74 | +To generate a package.xml 2.0 spec file for PEAR and build a PEAR package, just run: |
| 75 | + |
| 76 | + $ onion build --pear |
| 77 | + |
| 78 | +Then Your PEAR package is out! |
| 79 | + |
| 80 | +The `--pear` flag is optional. |
| 81 | + |
| 82 | +See: |
| 83 | + |
| 84 | + $ onion help build |
| 85 | + |
| 86 | +## Adding package dependencies |
| 87 | + |
| 88 | + [package] |
| 89 | + name = Onion |
| 90 | + desc = package description |
| 91 | + version = 0.0.1 |
| 92 | + author = Yo-An Lin <[email protected]> |
| 93 | + channel = pear.php.net |
| 94 | + |
| 95 | + [require] |
| 96 | + php = 5.3 |
| 97 | + pearinstaller = 1.4 |
| 98 | + pear.php.net/PackageName = 0.0.1 |
| 99 | + |
| 100 | +## Bundle |
| 101 | + |
| 102 | +Install PEAR dependencies into vendor/ directory |
| 103 | + |
| 104 | + $ onion install |
| 105 | + |
| 106 | +## Compile package to Phar executable/library file |
| 107 | + |
| 108 | +An example, we use onion to compile our executable file `onion`: |
| 109 | + |
| 110 | + $ onion compile \ |
| 111 | + --executable \ |
| 112 | + --classloader \ |
| 113 | + --bootstrap scripts/onion.embed \ |
| 114 | + --lib src \ |
| 115 | + --lib ../CLIFramework/src \ |
| 116 | + --lib ../GetOptionKit/src \ |
| 117 | + --output onion |
| 118 | + |
| 119 | +## Available Config Tags |
| 120 | + |
| 121 | +please checkout [doc/SPEC.md](https://github.com/c9s/Onion/blob/master/doc/SPEC-v2.md) |
| 122 | + |
| 123 | +## Version Naming |
| 124 | + |
| 125 | +version naming standard from PEAR group: <http://pear.php.net/manual/en/rfc.version-naming.standard.php> |
| 126 | + |
| 127 | +## Customize roles |
| 128 | + |
| 129 | +There are many built-in roles so that you don't need to define it by yourself, built-in roles are: |
| 130 | + |
| 131 | +- src/ php role |
| 132 | +- docs/ doc role |
| 133 | +- tests/ test role |
| 134 | +- \*.md doc role |
| 135 | + |
| 136 | +But you can add custom roles by yourself. |
| 137 | + |
| 138 | +```ini |
| 139 | +[roles] |
| 140 | +path/to/data = data |
| 141 | +path/to/library = php |
| 142 | +path/to/doc = doc |
| 143 | +``` |
| 144 | + |
| 145 | + |
| 146 | +A more detailed example |
| 147 | +======================== |
| 148 | + |
| 149 | + [package] |
| 150 | + name = your package name |
| 151 | + desc = package description |
| 152 | + summary = .... # optional, default to Description |
| 153 | + homepage = http://your.web.com # optional |
| 154 | + license = PHP # optional, default to PHP |
| 155 | + version = 0.0.1 |
| 156 | + version.api = 0.0.1 # optional, default to "version" |
| 157 | + channel = pear.php.net # default |
| 158 | + |
| 159 | + ; lead developer |
| 160 | + author = Yo-An Lin <[email protected]> |
| 161 | + |
| 162 | + ; other authors |
| 163 | + authors[] = Yo-An Lin <[email protected]> |
| 164 | + authors[] = Yo-An Lin |
| 165 | + |
| 166 | + ; contributors ... |
| 167 | + contributors[] = ... # optional |
| 168 | + maintainers[] = ... # optional |
| 169 | + |
| 170 | + [require] |
| 171 | + php = '> 5.3' |
| 172 | + pearinstaller = '1.4.1' |
| 173 | + |
| 174 | + ; pear package based on channel |
| 175 | + pear.channel.net/package = 1.1 |
| 176 | + |
| 177 | + ; pear package based on URI |
| 178 | + package = http://www.example.com/Foo-1.3.0 |
| 179 | + package = conflicts |
| 180 | + |
| 181 | + extension/reflection = |
| 182 | + extension/ctype = |
| 183 | + extension/pcre = |
| 184 | + |
| 185 | + [roles] |
| 186 | + |
| 187 | + ; mapping files to role |
| 188 | + your_script = bin |
| 189 | + |
| 190 | + ; glob is supported. |
| 191 | + *.md = doc |
| 192 | + *.php = php |
| 193 | + |
| 194 | + [optional remoteshell] |
| 195 | + hint = Add support for Remote Shell Operations |
| 196 | + channel/test = 0.1 |
| 197 | + channel/foo = 0.2 |
| 198 | + extensions[] = ssh2 |
| 199 | + |
| 200 | +## Hacking |
| 201 | + |
| 202 | +Make a fork from Onion and clone it: |
| 203 | + |
| 204 | + $ git clone [email protected]:c9s/Onion.git |
| 205 | + $ cd Onion |
| 206 | + |
| 207 | +Run onion to install dependencies |
| 208 | + |
| 209 | + $ bin/onion install |
| 210 | + |
| 211 | +To run unit tests: |
| 212 | + |
| 213 | + $ phpunit |
| 214 | + |
| 215 | +To test onion command: |
| 216 | + |
| 217 | + $ scripts/onion help |
| 218 | + |
| 219 | +To compile onion: |
| 220 | + |
| 221 | + $ scripts/compile.sh |
| 222 | + |
| 223 | +### PEAR Features not support yet |
| 224 | + |
| 225 | +Current `install` command does not support PEAR special features like: |
| 226 | + |
| 227 | +- PEAR Task: like replace content, rename ... etc |
| 228 | +- PECL installation |
| 229 | + |
| 230 | +## Community |
| 231 | + |
| 232 | +If you have questions about Onion or want to help out, come and join us in the #onion-dev channel on `irc.freenode.net`. |
| 233 | + |
| 234 | + |
0 commit comments