Blog Posts

Burlington PHP Users Group, December

I've been considering for a good six months trying to organize a PHP Users Group for the Burlington, VT, area. When we first moved to Vermont, I was surprised (and excited) by the number of PHP shops (which at the time I saw as job potential, as I was looking for work), and actually walked my resume around to a half-dozen or so. The area has a ton of PHP developers, and it only makes sense to have a UG where we can exchange tips and tricks of the trade.

Then, about six weeks ago, I mentioned this to my friend Rob. He did what I should have done all along, and googled for an existing group — and found one!

The Burlington, VT PHP Users Group has been around since November of 2005 on Google Groups, but we're having our inaugural meeting this coming Wednesday, 5 December 2007. I'll be speaking at this first meeting on Zend Framework's MVC components

If you're in the Burlington area this Wednesday, you should stop by. For more details, visit the event page, and don't forget to RSVP.

Continue reading...

I is a published author!

So, in addition to it being my daughter's birthday, which is exciting enough in itself, I received a package from my publisher, SitePoint, with my author copies of The PHP Anthology. Very exciting to see stuff I've written published!

Continue reading...

PHP Anthology, 2nd Edition is out

Well, it's now official: The PHP Anthology, 2nd Edition is finally out, and, as you'll see if you follow the link, I'm listed as an author on it. :-) It's a pleasant surprise to see it out — I finished my chapters back in January, and had almost forgotten about it.

Continue reading...

Gutsy Gibbon review

Early in the week, I decided to avoid the release rush and go ahead and update my laptop to Ubuntu's Gutsy Gibbon release. Overall, it's quite good, with one caveat I'll elaborate on later.

Continue reading...

ZendCon is over at last

ZendCon '07 is finally over, the dust has settled, and I finally find myself with some time alone… practically the first I've had since Sunday. The week was fantastic, and I had many good conversations and brainstorming sessions. Oh, and I ended up giving three different sessions, so it's time for links to slides and materials:

  • Best Practices of PHP Development. Sebastian, Mike, and I presented a full-day tutorial on PHP development best practices, focussing primarily on testing and testing strategies, but also covering coding standards, usage of SCM tools, and deployment. There were a ton of questions from the attendees, and Sebastian even whipped out some extra slides at the end showing new and little-known features of PHPUnit. Basically, reading the slides won't really indicate what we covered, but is more of a general outline. It was an honor and pleasure to work with Sebastian and Mike on this, and I hope we can do it again in the future some time.
  • Zend Framework MVC Quick Start. This was basically the same session I did in my webinar a couple weeks ago, with a few corrections and a small demonstration. Cal put me on directly following Terry Chay, in the largest of the four session rooms — the one where all the keynotes occurred — talk about intimidating! Amazingly, the session was really well attended — others I talked to estimate between 100 and 150 people showed up. The most amazing part, though, was that when I asked how many people knew what 'MVC' was, I don't think there was a single person who didn't raise their hand — definitely a sign of how well accepted the pattern now is in PHP.
  • AJAX-Enabling Your Zend Framework Controllers. I did this talk for the Unconference, mainly because its a topic I've been interested in and wanted to present. In it, I detailed how to ajax-enable an application through some easy tricks with Action and View Helpers and using JS to decorate your existing application. The reference app I used was a pastebin, and I've got code for both Dojo and Prototype flavors available:

The two highlight keynote speakers, for me, were definitely Joel Spolsky and Cory Doctorow. Neither spoke about PHP, but both spoke about topics that PHP developers should take to heart. Perhaps I'll elaborate on those in another post.

Another bonus for me was the number of old and new friends alike I got to see — I had many good conversations with Paul M. Jones, Nate Abele, Ivo Jansch, and Ralph Schindler, and opportunities to finally meet fellow co-author Lig Turmelle, Ben Ramsey, Chris Shifflet (dude, we've been to four conferences together, and never yet met!), and many, many others. I was also overwhelmed by the number of Zend Framework users who sought me out either to ask me questions or simply thank me and the others on the team for the project; I'm deeply honored that I can work on a project that affects so many developers.

And now for some down time to recuperate…

Continue reading...

oh, yeah, zendcon...

I don't know why I haven't blogged this sooner, but, yes, I'll be speaking once again at ZendCon:

I'll be presenting a number of times:

  • On Monday, I join Sebastian Bergmann and Mike Naberezny in a full-day tutorial session on PHP Development Best Practices and Unit Testing. This expands on what Mike and I did last year, and will more heavily emphasize the role of testing in the development process — arguably the most important best practice you can adopt.
  • On Tuesday monrning, I'll present a Zend Framework MVC Quick Start. This talk is based on a webinar I recently gave for Zend, and covers the various pieces of the MVC layer in Zend Framework.
  • Tuesday evening, I'll present an Unconference session on Ajax-enabling your Zend Framework controllers. I don't know yet if I'll need the whole hour, but I can probably fill it up with some examples of decorating your apps with AJAX.

Looking forward to seeing you all there!

Continue reading...

Zend Framework MVC Webinar posted

Last Wednesday, I presented a webinar for Zend entitled "MVC applications with Zend Framework". We had more than 50 attendees, most of whom stayed on the whole time. For those of you who attended, thanks for the great questions and comments.

If you would like to view the webinar, download the slides, or download the example code (a hello world app), visit the Zend.com Webinar page and look for the presentation; as of today, it's the first one on the list, but that will change as more webinars are presented.

Continue reading...

NYPHP Zend Framework Presentation

This past Wednesday, Zend's Chief Marketing Officer, Mark de Visser, and myself joined the NYPHP group for a special event meeting. Mark presented information on Zend's development stack and toolset (which I entirely missed, as I was still in transit), and I came in to give an overview of Zend Framework.

There were some great questions, and nice discussions following the event. If you live in New York and do PHP for a living, and haven't attended, you should; if you're ever visiting the area, see if you can attend a meeting!

Here are the slides. They're done using S5, a browser-based slideshow system. Simply unzip and double-click on index.html to start viewing.

Continue reading...

File_Fortune refactored

Over the past few evenings, I've refactored File_Fortune to have it implement Iterator, Countable, and ArrayAccess — basically allowing it to act like an array for most intents and purposes. As a result, I've eliminated the need for the File_Fortune_Writer package, and greatly simplified the usage.

(Note: sure, File_Fortune may not be that big of a deal, but over 1000 downloads in the past two years indicates somebody is using it. Plus, it powers the random quotes on the family website. :-) )

As some examples:

require_once 'File/Fortune.php';

// Initialize and point it to a directory of fortunes
$fortunes = new File_Fortune('/path/to/fortunedir');

// Retrieve a random fortune 
// (works with either a directory or a single fortune file)
echo $fortunes->getRandom();

// Set to a specific fortune file:
$fortunes->setFile('myfortunes');

// Loop through and print all fortunes
foreach ($fortunes as $fortune) {
    echo str_repeat('-', 72), "\n", $fortune, "\n\n";
}

// Hmmm.. let's change one:
$fortunes[7] = "I never really liked that fortune anyways.";

// No need to explicitly save, as it's done during __destruct(), 
// but if you really want to:
$fortunes->save();

// Let's add a new fortune:
$fortunes->add('This is a shiny new fortune!');

// and now we'll verify it exists:
$index = count($fortunes) - 1;
echo $fortunes[$index];

All-in-all, it's a much better interface. Lesson learned: when porting code from other languages, it pays to take some time and determine if there might be a better API in your own.

In upcoming releases, I hope to modify the backend to use PHP's Streams API instead of direct file access, and also to allow providing a list of fortune files explicitly. After that, I should be ready for the initial stable release.

Update (2007-07-10): fixed parse error in examples

Continue reading...

Globals, continued

Update: Sara has pointed out a flaw in my last case. The file loadFileWithGlobals.php was incorrectly loading the wrong file — it should be loading withGlobals2.php (updated now). When it does, access to baz2 works as it should.

As I note to in my comment, however, I stand by my original rant: relying on globals for your applications is a bad practice, as it makes them difficult to integrate with other applications later. Developers using your application should not need to hunt down exactly when a global is first declared and explicitly push it into the global scope in order to get that application to integrate with others. Use other means, such as singletons or registries, to persist configuration within your applications.


In my last entry, I evidently greatly simplified the issue to the point that my example actually didn't display the behaviour I had observed. I'm going to show a more detailed example that shows exactly the behaviour that was causing issues for me.

First off, this has specifically to do with including files from within functions or class methods that then call on other files that define values in the global scope. In the original example, I show an action controller method that includes the serendipity bootstrap file, which in turn loads a configuration file that sets a multi-dimensional array variable in the global scope. Without first defining the variable in the global scope, this method of running serendipity fails.

Now, for the examples.

Continue reading...