From 04ae71568bd7ae25b698b2d8e0ecf02d2662c0d9 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 12 Apr 2013 12:12:36 -0400 Subject: [PATCH] Closes #240: Explain how to manage PEAR dependencies with Composer --- _posts/04-03-01-PEAR.md | 44 ++++++++++++++++++++++++++++++++++++ _posts/11-01-01-Resources.md | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/_posts/04-03-01-PEAR.md b/_posts/04-03-01-PEAR.md index 61d0ce4..72e30b1 100644 --- a/_posts/04-03-01-PEAR.md +++ b/_posts/04-03-01-PEAR.md @@ -33,7 +33,51 @@ installing. See the [Using channel docs][4] for more information on this topic. * [Learn about PEAR][1] +### Handling PEAR dependencies with Composer + +If you are already using [Composer][5] and you would like to install some PEAR code too, you can use +Composer to handle your PEAR dependencies. This example will install code from `pear2.php.net`: + +{% highlight json %} +{ + "repositories": [ + { + "type": "pear", + "url": "http://pear2.php.net" + } + ], + "require": { + "pear-pear2/PEAR2_Text_Markdown": "*", + "pear-pear2/PEAR2_HTTP_Request": "*" + } +} +{% endhighlight %} + +The first section `"repositories"` will be used to let Composer know it should "initialise" +(or "discover" in PEAR terminology) the pear repo. Then the require section will prefix the package +name like this: + +> pear-channel/Package + +The "pear" prefix is hardcoded to avoid any conflicts, as a pear channel could be the same as another packages vendor name for example, then the channel short name (or full URL) can be used +to reference which channel the package is in. + +When this code is installed it will be available in your vendor directory and automatically +available through the Comoser autoloader: + +> vendor/pear-pear2.php.net/PEAR2_HTTP_Request/pear2/HTTP/Request.php + +To use this PEAR package simply reference it like so: + +{% highlight php %} +$request = new pear2\HTTP\Request(); +{% endhighlight %} + +* [Learn more about using PEAR with Composer][6] + [1]: http://pear.php.net/ [2]: http://pear.php.net/manual/en/installation.getting.php [3]: http://pear.php.net/packages.php [4]: http://pear.php.net/manual/en/guide.users.commandline.channels.php +[5]: /#composer_and_packagist +[6]: http://getcomposer.org/doc/05-repositories.md#pear diff --git a/_posts/11-01-01-Resources.md b/_posts/11-01-01-Resources.md index c6eed0c..cd3f258 100644 --- a/_posts/11-01-01-Resources.md +++ b/_posts/11-01-01-Resources.md @@ -26,7 +26,7 @@ * [PagodaBox](https://pagodabox.com/) * [AppFog](https://appfog.com/) * [Heroku](https://heroku.com) - (PHP support is undocumented but based on stable Facebook partnership [[link]](http://net.tutsplus.com/tutorials/php/quick-tip-deploy-php-to-heroku-in-seconds/)) + (PHP support is undocumented but based on stable Facebook partnership [link](http://net.tutsplus.com/tutorials/php/quick-tip-deploy-php-to-heroku-in-seconds/)) * [fortrabbit](http://fortrabbit.com/) * [Engine Yard Orchestra PHP Platform](http://www.engineyard.com/products/orchestra/) * [Red Hat OpenShift Platform](http://www.redhat.com/products/cloud-computing/openshift/)