CHAPTER 15 ■ AN INTRODUCTION TO PEAR AND PYRUS
channel.xml, which defines your channel. It also creates empty get/ and rest/ directories. I want these
to be Web-accessible later, so I ran the command in a Web directory.
Now that I’ve created a channel, I can add some categories.
php /usr/share/pearscs.phar add-category productivity "things to help you work"
php /usr/share/pearscs.phar add-category fun "the fun never stops"
The add-category subcommand takes two arguments: the name of the category, and a description.
It simply amends the channel.xml file.
Before I can add a package to the system, I must ensure that my new channel can be recognized or
PEAR, or Pyrus will complain when the package is built. In order to do this I need another Pyrus package:
PEAR2_SimpleChannelFrontend
Managing a PEAR Channel with PEAR2_SimpleChannelFrontend
Once again, the Pyrus site is not currently consistent about the best way to work with this package. The
suggested installation method:
php pyrus.phar install PEAR2_SimpleChannelFrontend
results in an error at the time of this writing. By the time you read this, you may get more useful
instructions on the package page at http://pear2.php.net/PEAR2_SimpleChannelServer. For now though,
you can get a phar file from http://pear2.php.net/get/PEAR2_SimpleChannelFrontend-0.1.0.phar. You
can also check http://pear2.php.net/get/ for more recent versions of the archive.
Now that I have the PEAR2_SimpleChannelFrontend phar file, I need to make it available via the
Web. I can do this by renaming the file to index.php and placing it in the Web-accessible directory that
houses channel.xml. This location should match up with the domain and subdomain that define the
channel. So, earlier I chose the name pear.appulsus.com for my channel. I should configure Apache 2 so
that pear.appulsus.com resolves to the directory in which I've placed index.php. Here’s an extract from
my httpd.conf file (that is the Apache Web server’s configuration file):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/pear
ServerName pear.appulsus.com
ErrorLog logs/pear.appulsus.com-error_log
TransferLog logs/pear.appulsus.com-access_log
This simply ensures that a request to http://pear.appulsus.com is routed to the DocumentRoot
directory (/var/www/pear) in which I placed the newly renamed index.php. The
SimpleChannelFrontend packages also requires that some mod_rewrite directives are applied to the
channel directory:
<Directory "/var/www/pear">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule. index.php [L]