Building and Maintaining a PEAR Server with Pirum
Pirum is a simple PEAR channel server manager that was built by Fabien Potencier. The Pirum project allows you to easily setup a PEAR channel and publish your own packages quickly. This quick blog post / article will get you going with it in no time.
There are a few things that you must have already to get going on this exercise (besides PHP and a Web Server *Note: you can do it without these):
- SSH access
To install Pirum we are simply going to be running a few commands against PEAR:pear channel-discover pear.pirum-project.org pear install pirum/Pirum-beta
Pirum should now be installed, we now need to setup the pirum.xml file to describe your server.
Creating the PEAR Structure for Pirum
Pirum requires a pirum.xml file that is a very simple XML file. You place this into the directory that you would like your pear server to live. Let's say for the sakes of this post that it is /var/www/pear. We create a file /var/www/pear/pirum.xml file that contains the following XML (to be explicit you will change the XML values to your liking)pear.mydomain.com PEAR Server for MyDomain mydomain http://pear.mydomain.com/
The fields in the pirum.xml file are explained as follows:
- name: The name is typically the domain name to the PEAR channel. You should keep this the same since this is how just about every PEAR channel references itself.
- summary: A very short summary about what the channel is, generally the name of the project / components that sit inside of it
- alias: utilized when upgrading or installing, you can reference a package by aopear install alias/package_namea
- uri: The external URI that people will run aopear channel-discover uria
Making it Work
We can now build the main repository. We will not add any packages at this point but to get the main repository running and viewable from a web server. We will need to run the command:pirum build /var/www/pear
At this point you should see that pirum is building out a few files such like the following:INFO Building channel INFO Building maintainers INFO Building categories INFO Building packages INFO Building releases INFO Building index INFO Building feed INFO Updating PEAR server files INFO Command build run successfully
We now need to attach a web server to simply be able to access this directory. In your virtual hosts file or dedicated server add an entry to /var/www/pear that can be accessed from the uri we created in the pirum.xml file. You should not be able to see the index.html file for the packages that are installed in the repository (which is none at this point
Creating a Package
In order to create package, you should have some form of reusable code that is able to be deployed into a PEAR channel. This might be a private or public repository - either way, it is the same exact process. You must first create a package.xml file for the individual package in a top level before your package. Don't worry, this is not needed on the same environment as we are going to create a .tgz package from it (tar gzip). Once you have completed the package.xml file and have created your .tgz file, we are moments away from being able to add a package into pirum.
Once the package is up on server with pirum - utilize the following command:pirum add /var/www/pear package.tgz
This will add in the package and
Truncated by Planet PHP, read more at the original (another 3015 bytes)