Posts Tagged ‘pear2’

A New PEAR Channel Frontend

December 21st, 2009

It seems like PEAR2 has been brewing forever. I mean, we’ve been talking about PEAR2, namespace usage, and a brand new installer for a long time. But, now that PHP 5.3.0 is a reality and 5.3.1 is so close out the door – things are actually taking shape and getting to the point where not only can we show you what we’ve been working on, but you can actually try things out for yourself.

What I’ve been working on the past couple of days months is a new PEAR channel frontend; the basis for the PEAR2 website. I wanted a simple PEAR channel frontend, that just looks at the local filesystem for all the channel info, and would display the basics: what packages are available, categories, releases etc. Basically, just a simple web view that would not need a database backend, or any complex installation.

It would be simple to create a standalone library that just parsed xml files and read out the data, but having each underlying piece a reusable component would be very beneficial.

  • a simpler XML library for parsing files
  • an HTTP request library
  • a library to talk to PEAR channels
  • a simple templating system with php as the template language
  • html/css templates to present the content in

So when you consider the all the pieces that are required, this is quite an undertaking.

Implementation:

Ordinarily the pear installer, or pyrus, communicates to a PEAR channel through the xml files that describe the packages available. What we’ve done, is used the installer as the backbone for channel discovery and information retrieval, and we’ve told it to look at the local filesystem instead of at a remote channel. This is done using a “filesystem” adapter for the PEAR2_HTTP_Request package, which turns your local filesystem into a fake Internet. This is a fairly simple concept, that makes for a very simple PEAR channel frontend.

So, if you couple that model for data retrieval with a completely new PHP 5.3+ template system with roots in Savant, we’ve got a really nifty base for building pear channel websites.

So! The package is in the pear2 sandbox and is titled PEAR2_SimpleChannelFrontend as a companion to the PEAR2_SimpleChannelServer which makes channel creation (with categories!) a breeze.

I’ve added it to my local PEAR channel by simply dropping the .phar file in the web root as index.php, add a small .htaccess file and that’s all that is needed. Check it out at http://pear.saltybeagle.com/

As of tonight you can try it out for yourself by grabbing the PEAR2_SimpleChannelFrontend-0.1.0.phar off of the PEAR2 website and saving it along side your channel.xml and browsing to the phar file. I named it index.php for simplicity, and placed the following .htaccess file in place:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Also, my thanks to Amir for the coding help with SimpleChannelFrontend, and the pear2 site. Things are moving along quite nicely.

Autoloader That Installs PEAR Packages

November 4th, 2009

I had a thought the other night about an autoloader that could install pear packages automatically for you.

Security concerns aside, I thought this would be a fun/juvenile coding experiment, and something that could showcase how easy the pyrus api is for installing PEAR packages. So here it is, pushed out on github – http://github.com/saltybeagle/AutoloadPackage/blob/master/AutoloadPackage.php

Only 56 lines of code to have an autoloader that will install a PEAR2 package. Now if that’s not fun, I don’t know what is.

:-)

Oh, and you should really check out Pyrus, the new PEAR installer. Get it over at the pear2 website (under construction).