php

04 Jan

Fortissimo and Pilaster: Two projects

in documentdb, framework, mvc, php, programming

I have released two projects today:

  • Fortissimo: A PHP framework with a twist. It's scalable, it's not MVC, it's fast, and it's NSFW!
  • Pilaster: A pure PHP document database that provides similar services to MongoDB or CouchDB -- only without the server.

Both are still under heavy development, but they are now at the point where others can start testing them and playing with them.

26 Dec

Phing: Fixing Output on OS X

in mac, os x, phing, php

Using Phing on a Mac OS X console sometimes has a strange result: While the Phing script runs correctly, the console displays nothing. The reason for this is that the ANSI color codes used by some versions of Phing are not supported by OS X.

The solution is simple. Change the output logger.

$ phing -logger phing.listener.DefaultLogger ftest

This will use a non-colorized logger.

01 Dec

Streamlining Iterators in QueryPath 3.x

in performance, php, php 5.3, querypath

Work has officially begun on QueryPath 3.x. The upcoming release is focused on implementing and supporting many of the new features introduced in PHP 5.3, including enhanced SPL support, namespaces, closures, and phar archives.

In an earlier article, I examined the performance of various iteration strategies in QueryPath. After taking a hard look at the patterns I observed there, I revisited QueryPath's QueryPathIterator class to see if I could make a sizable performance improvement.

26 Nov

Iteration Techniques and Performance in QueryPath

in performance, php, php 5.3, querypath

QueryPath provides multiple methods of iterating. This article demonstrates the performance impact of various looping types. In this article, we are going to look at four different ways of iterating through the items wrapped by a QueryPath object:

  • Using QueryPath's iterator
  • Looping through DOMNode objects
  • Using each() and a callback
  • Using each() and an anonymous function

This last item is specific to PHP 5.3 and later, and offers intriguing possibilities when paired with closures.

Finally, at the end of the article, I will show some representative performance numbers.

22 Nov

Installing XDebug 2 on Mac OS 10.6 Snow Leopard (with PHP 5.3)

in os x, php, snow leopard, xdebug

A while back, I wrote an extensive article on installing XDebug on OS X with MAMP. Now that I have Snow Leopard, I am making a new attempt at working with XDebug on OS X. This article discusses working with XDebug 2.0 or greater on Mac OS 10.6 with PHP 5.3, as packaged with OS X. Continue on for step-by-step instructions. (For more notes on upgrading a PHP dev environment for Snow Leopard, read this article.)

21 Nov

PHP Developer's Snow Leopard Upgrade Notes

in git, os x, phing, php, phpdocumentor, programming, snow leopard, xdebug

I'm upgrading to Snow Leopard, and I intend to switch from MAMP to the built-in PHP/Apache 2 configuration. As a PHP developer, there are several notable things that I wanted to track as I performed my upgrades. This article tracks those changes

PHP 5.3PHP 5.3
My current OS 10.5 toolchain for PHP was this:

  • PHP 5.2.6 (MAMP)
  • Apache 2 (MAMP)
  • MySQL 5 (MAMP)
  • TextMate
  • Git
  • XDebug
  • Several PEAR packages installed into MAMP's PHP 5, including PHPUnit, PhpDocumentor, Phing, and XDebug

One of the desired outcomes was to switch to the OS X version of PHP and Apache, which is tenable now that PHP is more robust (and now that I know how to use PEAR with the OS X version). It's also desirable because Snow Leopard is now running PHP 5.3. Here are my notes on the upgrade.

Update: Problems with PHPUnit and Phing.

20 Nov

QueryPath Performance Optimizations on Reduncery

in drupal, php, programming, querypath, reduncery, twitter

Continuing a trend on the non-evilness of optimization, this article discusses some methods of improving performance in QueryPath.

Early this week, a Twitter analysis tool called Reduncery was launched by a friend of mine. Reduncery calculates how much of a "redunce" a particular user is -- that is, what percentage of a user's tweets are retweets (RT). It can also calculate how ineffective it is for one person to retweet another. In this case, it calculates the overlap in the followers of the original tweeter with the followers of the retweeter. In what follows, we will look at the ways Reduncery optimizes QueryPath to keep page load times down.

18 Nov

Reduncery: Calculating retweet idiocy

in php, querypath, twitter

Ever get irritated by reading the same tweet multiple times, retweeted by the same old people? Ever wondered how effective re-tweeting is? Are new people really reading the tweet, or are the same people just being notified multiple times? You can now find out for sure with Reduncery.

RedunceryReduncery

Reduncery was built on QueryPath and Drupal. In a future blog, I'll tell you about some of the the performance optimizations Reduncery uses to speed up searches of 200k+ users.

17 Nov

Creating a Custom Phing Task

in phing, php

Out of the box, Phing provides numerous features for creating high-powered source code management scripts. In an earlier post, I talked about metaprogramming in Phing, merely scratching the surface of what Phing can do. In this article, I want to illustrate how easy it is to extend Phing.

Phing can move, copy, package, unpackage, modify, touch, and delete files. But one thing it can't do out of the box is download files. In this short article, I will illustrate how easy it is to build a new Phing task to download a file from an arbitrary URL.

The desired goal it to make it possible to write a phing task that looks like this (in the build.xml):

  <download url="http://example.com/mypackage.tgz" tofile="SomeFile.tgz"/>

This task, when executed, should download the package from the target url and, if tofile is set, store the file with the name given there.

Doing this is going to involve two parts:

  • Writing the task in PHP.
  • Telling Phing, in the build.xml, where the new task is.

The first part is the harder of the two... it'll take a couple dozen lines of very basic code.

10 Nov

Five Ways to Metaprogram PHP with Phing

in phing, php, phpdocumentor, phpunit

There are a handful of PHP development tools that I find myself using project after project. One of them is Phing, a PHP-centered build tool similar to Ant, rake, or GNU Make.

The primary purpose of Phing is to make it easy for PHP developers to write build scripts for our applications. If you are familiar with Ruby on Rails, you might compare this to rake's usage. rake makes it easy to manage your Rails application. You can rebuild the database, start and stop the webserver, and so on from within rake.

Phing uses a declarative XML language to create targets (commands you can run) that are composed of tasks (individual steps for each command). Phing is built entirely in PHP, and is easily extended. Even without writing a line of PHP, you can squeeze a seemingly endless number of tasks out of a Phing script.

Here are some common tasks I use Phing for in my PHP projects. The first four meet some common needs. The last one is by far the coolest, though.

  1. Let Phing catch your typos.
  2. Automate Your Automated Testing.
  3. Let Phing Write Your Documentation
  4. Package Your Applications
  5. Build Your Own Toolchain