In a recent post from Eric Adams, he shows how to use the SplObserver and SplSubject components of the Standard PHP Library (SPL) to make an implementation of the observer pattern for more reusable code.
As PHP applications grow into complex object-oriented systems, developers look to create centralized components to execute repetitive tasks. These include logging, emailing, redirects, and more. The Observer pattern is a commonly used design pattern to hook such components into an application during runtime, thereby making them reusable. Since PHP 5.1, there are two interfaces built into the Standard PHP Library (SPL) that can be implemented to use the Observer pattern in your application. They are SplSubject, and SplObserver.
He shows how to use them in an example of a custom error handler class that extends the SplSubject with its attach, detach and notify methods as well as logger and mailer classes that will use it to handle their exceptions.
Fawad Hassan has posted the second part of his CodeIgniter and jQuery tutorial series about creating a simple CRUD (create, read, update, delete) interface using these simple but powerful technologies. This is a continuation from this first part of the series.
In this second part you’ll learn how to:
- put in an Ajax loader image as the requests are made,
- make update and delete calls to you backend and
- how to use jQuery’s delegate method to bind events.
You can grab the source of the examples to get started right away or follow through the tutorial that comes complete with screenshots, code snippets and explanations of how it all first together.
Dougal Campbell has posted a review of a book targeted towards both WordPress beginners and pros – “Digging Into WordPress” by Chris Coyier and Jeff Starr.
I spent some time looking over it, And wanted to share my impressions. If you’re in a hurry and just want the 5-second review: It’s good, and it’s got something for beginners and experts alike. If you want a more in-depth look, then please read on.
The book weighs in at 400 pages and eleven chapters covering all sorts of topics like themeing, security, installation of a fresh version of the code, plugins and custom development. There’s also an archive included with the book with all of the code and plenty of examples to get you headed in the right direction.
You can find out more about the book – and order your copy – from its website.
In a new post to his blog Kevin Schroeder takes a look at how Zend Server and Zend Server Cluster Manager can fit together to help make maintaining your multiple-machine web server cluster simpler.
PHP is designed using a shared-nothing architecture. [...] That’s great! It makes for a very stable, very easy to use architecture. But what happens when you go beyond one server? [...] Managing a hundred servers is quite different from managing one. Heck, managing three servers is different from managing one.
Zend Server gives you all sorts of tools to help manage and monitor the server it runs on, but when you start clustering these servers, the maintenance can be a huge headache. The Cluster Manager comes in and helps with centralized configuration, monitoring, sessions clustering and more. Kevin briefly talks about setting it up (a call to yum install the package) and a few steps through a browser-based GUI interface to get the ball rolling. He’s also included a screencast to show each step of the way.
New on his blog today Rohit Chauhan shares some handy shortcuts for the PHP developers out there using Eclipse as their IDE to help make their work even faster.
He’s made a few other posts and this follows along with the theme with tips on:
- Adding files to a SVN project through the interface
- Pushing changes to your version control system
- Synchronizing data from your repository
- and a few shortcuts that can make small things simpler – jumping to a line number, find last edit location, moving through open files and more.
Because of a recent addition to the the Gentoo PHP package (FPM support) they’re looking for people to test it out and report back the results. To help, Ole Markus has written up some instructions on how to get it up and working on your system with nginx.
PHP just added the FPM patch to their 5.3 branch, making it likely that PHP 5.3.3 will support the FPM SAPI. The FPM SAPI is an improved fcgi SAPI that allows for more advanced configuration than the original fcgi SAPI. One of the most useful features is process management, which makes it very useful for lightweight webservers, such as nginx, that does not handle process management of fcgi themselves.
There’s only a few commands you’ll need to get this new package installed and working with your local nginx install with the help of the emerge and layman tools. He also includes the configuration change you’ll need to make to the nginx config file to get it working as a FastCGI module.
On the Codrops blog there’s a recent tutorial posted showing how to create a fully-functional image slider/viewer with a combination of HTML, jQuery and a bit of PHP (here’s a demo).
In this tutorial we are going to create another full page image gallery with a nice thumbnail area that scrolls automatically when moving the mouse. The idea is to allow the user to slightly zoom into the picture by clicking on it. The thumbnails bar slides down and the image resizes according to the screen size.
Based on this tutorial, they show you how to build on it and add a few new features like a changing cursor depending on its position in the current image. The show the folder structure you’ll need, the HTML and PHP to make the backend work and the CSS and Javascript to round out the frontend. If you want to skip straight to the good stuff you can also just download all the code and get started.
In a recent post to the FinalConcept blog there’s a helpful hint for Symfony developers looking to be rid of a pesky “unexpected form field” error that might pop up – finxing it with a validator.
In this use case we have an exiting model that describes an Article. We want to be able edit the Article and have the option to send and email to an address defined in a text box. However we don’t want the email field to be bound to the form and we dont want to add the email address to the Article.
The trick is to add a validator to the form’s definition (like a normal field) but to include a “sfValidatorPass” into the validatorSchema and it’ll skip right over it. You can find out more about Symfony forms on the Symfony project website.
On the Linode Library there’s a recent tutorial posted about deploying Drupal sites (high performance ones) out to production server with the help of Project Mercury StackScript Linode offers.
This high performance Drupal system is based on the work of Project Mercury. Project Mercury aims to increase the performance and ability of Drupal powered websites to respond to increased load. This document leverages the same collection of popular open source tools including the Varnish Accelerating Proxy, the APC bytecode cache for PHP, Memcached for accelerating database operations, and the Solr search engine.
The tutorial shows you how to get the software you’ll need installed, and includes details on how to configure each of them for maximum performance – Drush, Apache, Varnish, Solr, Pressflow and, of course, Drupal. All software is installed via packages to make things much simpler and snippets of configuration files and commands are included to make the setup relatively painless.
On Developer.com today there’s a new article talking about some of the PHP-related improvements in the latest version of the PHP Development Tools (PDT) extension for Eclipse including template assistance and improved debugging.
Among the 39 projects included in Eclipse Helios is the PDT (PHP Developer Tools) 2.2 release. The PHP Eclipse project was first announced back in 2005, with version 1.0 coming in 2007. With the PDT 2.2 release, the project has continued to evolve with new features as the project’s popularity has grown.
New features include a template content assist feature that will help make it easier for developers to get an application up and running quickly and better debugging support via a new inspection tool to help evaluate PHP expressions. The post also includes some quotes from Andi Gutmans of Zend on the progress PDT has made and some thoughts on one of its competitors, Netbeans.