Archive for the ‘PEAR’ category

Simple Guidelines for Proposing a PEAR Package

January 24th, 2007

Recently I went through the proposal process for a PEAR package (Services_W3C_HTMLValidator) and figured I would write down some thoughts.

Simple Guidelines for Proposing a PEAR Package ( and getting it approved ):

1. Lose your ego (if you have one). Your code might be good, but there are plenty of people out there who will find flaws with it. The sooner you realize others can help you, the sooner you can move on to accepting help and improving your code.

2. Choose an appropriate package name. And be sure you understand why the underscores are in package names. Examine what packages are out there, and note their category and naming scheme — the package name should quickly convey the purpose of your package. Also make sure you look to see if your package is already in the repository.

3. Follow the coding standards. PEAR developers will nitpick you to death – it’s best to just correct this ahead of time. The biggest ones are: Use 4 spaces, not tabs! Take a look at PHP_CodeSniffer and run your code through this before you submit any code.

4. Document your code. If you expect anyone else to use your code, you MUST document it. Provide internal documentation using PHPDoc syntax – AND externally using general terms anyone can understand.

5. Provide useful examples. You must have examples which work and are easy to understand – and you MUST have examples which cover the basic functionality your package provides.

Chiara_PEAR_Server Release Droplet for Mac OS X

December 16th, 2006

Hey, my first Mac Application! (which can hardly be called an App at all)…

This is a Mac OS X droplet for PEAR developers that run Chiara_PEAR_Server. This little droplet just takes in your PEAR Package .tgz and it will release it to Chiara_PEAR_Server.

Just drop your package.tgz onto the droplet, the script examines the .tgz, discovers the channel name it should be released to, prompts for your PEAR channel handle and password and saves the release to the server.
Note: It assumes your admin.php file is located at http://pear.examplechannel.com/admin.php

A very targeted audience, but none-the-less, a handy little droplet I use to deploy releases.

Source is at svn.saltybeagle.com.

This was built using Platypus, CocoaDialog, and my Salty_PEAR_Server_RemoteReleaseDeployer.

The PEAR Installer Manifesto

December 14th, 2006

I recently finished a book on the PEAR installer written by Greg Beaver. The book itself is an excellent read for anyone who develops installable PHP libraries or applications, and one I would highly recommend for anyone interested in building small to large PHP web applications.
The PEAR Installer Manifesto by Greg Beaver
Throughout the book, Greg demonstrates the complex features of the PEAR installer and package description file (package.xml) to guide you through understanding methods of distributing, installing, and maintaining PHP (and other) projects. The book is filled with real world examples and working applications from the guy who (seriously) ‘wrote the book’ on the PEAR installer.

To anyone who is building distributed PHP applications or reusable libraries, this book is a must have for understanding release deployment strategies and how they are managed with powerful ease. The author knows his stuff, and has used every one of the examples within real word applications. The book has everything from “Hello World” installable applications to a full blown source code repository and distribution system through PEAR channels.
With the book you will have all of the necessary information to build and maintain your complex PHP applications and easily distribute them across many servers, clients, or the open source community.

If you’re at the point in your application development where the unzip-and-go distribution method has reached its limit (typically the first bug after the first zip), the time has come to start building installable PEAR packages and to take advantage of all the capabilities the PEAR installer offers.

Despite maintaining my own PEAR channel server (pear.unl.edu) for over a year now, I still found plenty of information to continue the ease with which the PEAR installer offers. So even if you are an experienced PEAR developer, the book is still a good read and shelf reference.

I highly recommend the book, check it out.

PEAR Installer Manifesto by Gregory Beaver

Update to Services_W3C_HTMLValidator

December 3rd, 2006

I updated the PHP API interface to the W3’s html validator with two new methods:

validateFile($file)

validateFragment($file)

The two methods allow you to validate a local file which is uploaded to the validator, or a string of html code.

Test it out or comment on the PEAR proposal.
Download Services_W3C_HTMLValidator
Comment @ PEAR Proposal for “Services_W3C_HTMLValidator”

PHP Interface to the W3 HTML Validator

November 28th, 2006

Last night a co-worker mentioned the W3’s new API for their HTML Validator, which sounded pretty handy.

I searched around on the Internet and found a few people who had scratched some things together to read the SOAP 1.2 response data, but nothing object oriented and re-usable the way I would need it to be. So I went ahead and coded up a simple PEAR Package which will connect to the W3’s validator and check if a given URI is valid.

In our office we have talked about developing a tool that would automatically crawl a site to do simple blind validation, and this tool will be a starting point for that system.

Today I proposed the package to pear.php.net, and plan on continuing development if not on pear.php.net at least on my own channel pear.saltybeagle.com.

Wish me luck… this is my first pepr proposal in about 2 years… and a PEAR package which might actually be worthwhile for others.

Check out my proposal for Services_W3C_HTMLValidator.

Scripting Releases to Chiara_PEAR_Server

November 6th, 2006

I’ve been working on some ways to automate release deployment to my PEAR Channel Servers (pear.unl.edu, pear.saltybeagle.com) running Chiara_PEAR_Server.
Right now I have scripts that automatically create the package.xml file using PFM2 and the package tgz files but uploading the release was still a manual process.
The process isn’t that complicated, you log in to the channel server, and upload a file…. the server handles the rest (haha, so punny).

So finally I got friendly with HTTP_Request and wrote a simple class/script to remotely release a pear package to a Chiara_PEAR_Server.

Now it’s even easier to release early, release often.

<?php
/**
 * sample usage of the Salty_PEAR_Server_RemoteReleaseDeployer
 */

require_once 'Salty/PEAR/Server/RemoteReleaseDeployer.php';

$d = new Salty_PEAR_Server_RemoteReleaseDeployer();

$d->adminuri = 'http://pear.saltybeagle.com/admin.php';
$d->username = 'adminhandle';
$d->password = '1234';

if ($d->deployRelease('/home/bbieber/workspace/Salty_PEAR_Server_RemoteReleaseDeployer/Salty_PEAR_Server_RemoteReleaseDeployer-0.0.1.tgz')) {
    echo 'Success!';
} else {
    echo 'Something went terribly wrong.';
}

So what the heck, I made it into a PEAR package.

Salty_PEAR_Server_RemoteReleaseDeployer

Hooray for PEAR Channels!

First Release of Salty_Savant_OutputControl

August 27th, 2006

Today I released 0.0.1 of a Savant template output controller I’ve been experimenting with.

It’s a simple package which automatically correlates objects with their Savant templates.

The paradigm I’m using is to build everything into an object with member variables for the changing/dynamic content. With this, each object has a corresponding template which will output the member variables. The Salty_Savant_OutputControl package automatically populates the Savant templates before they are sent to the client.
It also handles arrays of objects or strings, and even supports optional template output caching with Cache_Lite. Relatively few lines of code, but they really help out when you have 30 DB_DataObjects and want templates for each object to quickly work, and play nice with one another.

I think of this package as the quick bridge between your disparate logic and presentation.

I’ve included a simple example in the package, and I’d be interested in any feedback people have – whether I should have used a Savant plugin, if this is a good idea or bad, etc.

At any rate, I think it’s useful.

Check it out:
Salty_Savant_OutputControl

PEAR Channel Server Now Operational

August 27th, 2006

My personal PEAR channel server has just been set up at http://pear.saltybeagle.com/.

The first task was a rewrite of the Chiara_PEAR_Server post-install scripts to use MDB2_Schema, and some other small changes to get things running.

This is the second channel server I’ll be managing, and this one will be the personal companion to my work PEAR Channel Server http://pear.unl.edu/.
I’ll use this to put out small simple packages I frequently use at home, as well as testing for my help on the Chiara PEAR Channel Server.

Yea for PEAR Channels.

Use Dreamweaver Templates as PHP Objects

January 27th, 2006

Yesterday I finished up the first release of a PEAR package for using Macromedia Dreamweaver templates as PHP objects.

The package is named UNL_DWT (eventually may be renamed HTML_Template_DWT), and is now available on the UNL PEAR Channel server.

This package builds PHP classes for your .dwt files with member variables for editable regions.

This is a simple abstraction of page presentation and programmable content, but is useful in large organizations that use Dreamweaver templates for their page designs.

[Some of you may be asking, why another damn templating engine?]

The problem with other template engines is that they use unique syntax that can’t be sent to a browser without processing, and (without 3rd party plugins) aren’t integrated into major HTML Editing Applications.

Dreamweaver uses HTML comments to define editable content regions which ensures pages can be sent to a browser without any processing, while still allowing the templates to be used in other editors.

Designers can build a site design within Dreamweaver and use that design in static HTML files, pages editable with Macromedia Contribute, and now — programmer friendly PHP objects.

One set of templates can be used by users who understand any web publishing application, used as static (x)html pages, ASP pages, PHP pages, as well as PHP programmers who prefer to use the templates as objects.


[Where is this going?]

This package was a necessary foundation for creating a UNL PEAR channel package for the UNL Templates that can be easily adopted across all of the PHP servers at our University.

We currently distribute a zip file with the Dreamweaver templates to over 120 registered web developers on campus, who use the templates in every application imaginable. Dreamweaver templates suit our needs to use one design across such a wide variety of applications, but for those familiar with PHP it would be easier to distribute the UNL templates as a PEAR package and be able to use them as objects.

- That’s where this is going.

Get the package at http://pear.unl.edu/

Learn more about how the University of Nebraska-Lincoln (UNL) is organizing it’s web developers to create a consistent web design at the university.
http://www.unl.edu/webdevnet/

PEAR Channel Server

September 26th, 2005

I’ve finally finished setting up a PEAR Channel for UNL using Chiara_PEAR_Server.

http://pear.unl.edu/

The process is quite complex, at least with the current state of things. Greg Beaver has built a sample PEAR Server installable using PEAR.

The simple way to set up a PEAR Server using available packages should be:

sudo pear channel-discover pear.chiaraquartet.net
sudo pear install -f –alldeps chiara/Chiara_PEAR_Server
sudo pear run-scripts chiara/Chiara_PEAR_Server

Then answer all the questions and it should create the Database, Tables, Admin user login, and write out a file to your document root.

In fact there is a ‘Tutorial’ out there by Tobias Schlitt that basically states exactly that. But I had some trouble along the way.

Changes:

360d359
< return false;
361a361
> return $a;
381c381
< if (!$this->lastversion) {
---
> //if (!$this->lastversion) {
400c400,401
< $dbo->channel = $answers['name'];
---
> $dbo->channel = $this->channel;
404c405
< $dbo->channel = $answers['name'];
---
> $dbo->channel = $this->channel;
412c413
< }
---
> //}
417a419
> /*
420a423
> */
616,617c619,620
< $phpdir = str_replace('\\', '/', 'C:\php5\pear');
< $datadir = str_replace('\\', '/', 'C:\php5\pear\data');
---
> $phpdir = str_replace('\\', '/', '/usr/local/php5/lib/php');
> $datadir = str_replace('\\', '/', '/usr/local/php5/lib/php/data');

With those fixes, I was finally able to get Chiara_PEAR_Server working.