PHPDeveloper.org

Syndicate content
Up-to-the Minute PHP News, views and community
Updated: 23 weeks 1 day ago

Brandon Savage's Blog: The Registry Pattern Reexamined

Fri, 2010-03-26 17:57

Brandon Savage takes another look at a popular design pattern - the registry pattern - and how he's changed his thinking on its use a bit on how (or if) it should be used in your applications.

Last July, I wrote about the registry pattern and some of its advantages. These advantages include the ability to access objects across different areas of your application, and the storage of objects for later retrieval. [...] For me, over the last few months, I've discovered two reasons why I advise against the Registry Pattern: first and foremost, it discourages unit testing, and secondly, it discourages good design.

He goes on to elaborate on why these to things could be so detrimental to your code including the problems it can cause in tests being a point of failure and that it can make you application sloppy by giving you an unpoliced "bucket" to drop things in without any context to where they fit in the site.

So what's his suggestion to replace this bit of functionality and make things both easy to test and simpler to keep structured? Dependency injection.

Categories: Php, PHPDeveloper.org

William's Blog: A Popurls Clone with PHP, jQuery, Awesomeness

Fri, 2010-03-26 16:48

In a new post to his blog William shows you how to create a Popurls clone with the powerful combination of PHP and jQuery. Popurls is an aggregation site with some of the latest news and happenings from all around the web.

Since I have a crazy workload right now, I feel this is the perfect time to write a quick n' dirty tutorial on how to build your very own Popurls. Impress your friends and/or boss with a nifty, hand made news aggregator. Yes, very buzz word friendly.

He uses the SimplePie library to pull in the information from various feeds including Digg.com, Reddit.com, Wired's news feed and Engadget. He shows how to use regular expressions to extract information from the feeds (if they're uncooperative), a bit of PHP to work around potentially empty fields and the full jQuery/HTML/CSS you'll need to make it look more like this

Categories: Php, PHPDeveloper.org

Lukas Smith's Blog: Horizontal Reuse aka Traits Reloaded

Fri, 2010-03-26 15:38

In a quick post to his blog Lukas Smith talks about the proposal for traits support that's been pending for PHP for a while now. Recent updates have been made to it, so it's come back up to the front of developer's minds:

Stefan has since tweaked the proposal and in the latest version it includes an alternative approach called Grafts along with the original Traits idea, which is essentially language level delegation pattern support. I am absolutely sure that we will either see Traits or Grafts in the next non patch release of PHP (aka 5.4 or 6.0).

Lukas would like to see the support go in sooner than later, so he requests some comments and thoughts on the proposed functionality and to leave them as comments on his blog entry.

Categories: Php, PHPDeveloper.org

SitePoint PHP Blog: How to Handle Unloaded PHP Extensions at Runtime

Fri, 2010-03-26 14:10

On the SitePoint PHP blog today Craig Buckler has a suggestion on how to handle unloaded extensions in your application in case you need to define a failover.

Unless you're creating very simple applications, you will soon require one or more PHP extensions. Extensions are code libraries which extend the core functionality of the language. [...] What happens when you want to move your web application to another host or platform where a different set of extensions are configured?

Using the extension_loaded function built into PHP, you can create intelligent code that can fall back on a different technology if needed. In his example its trying to check for the GD graphics extension and echoing and error message if it's not found. The function_exists function can be used similarly.

Categories: Php, PHPDeveloper.org

NETTUTS.com: CodeIgniter from Scratch: Shopping Cart

Fri, 2010-03-26 13:08

On NETTUTS.com there's a new tutorial looking at the CodeIgniter framework and using the shopping cart class that it comes bundled with to create a simple cart system based on this library.

Today, we are going to take a look at the Shopping Cart library for CodeIgniter. This useful class allows us to add and remove items to a shopping cart, update them, and calculate prices. I will demonstrate how you can build a simple shopping cart system with the help of this library.

This is the latest in their "CodeIgniter from Scratch" series so, if you're not overly familiar with the framework, you might need to go back and start from the beginning and work your way up. The screencast steps you through the shopping cart creation and an image of the end result is also included. You can also download the source to make it easier to follow along.

Categories: Php, PHPDeveloper.org

Kevin van Zonneveld's Blog: Redis PHP Introduction

Fri, 2010-03-26 12:46

Kevin van Zonneveld has written up a new post for his blog today looking at using Redis in your application for caching information (similar to memcache).

Don't know Redis? Think Memcache, with support for for lists, and disk-based storage. You can use Redis as a database, queue, cache server or all of those combined. [...] Redis keeps the entire dataset in memory, so it's still crazy fast: 110000 SETs/second, 81000 GETs/second. Good enough for to you? [...] Yes, you can store (serialized) arrays in Memcache. But every time you change 1 element, you'd have to invalidate & overwrite the entire array.

He talks about installing the redis server (a simple task if you use the package management tool for your linux release) and some simple code to push data into the caching server for keys, lists, sets and how to pull the information back out sorted.

Categories: Php, PHPDeveloper.org

Justin Tadlock's Blog: Looking forward to WordPress 3.0

Thu, 2010-03-25 18:22

In a recent post Justin Tadlock takes a look ahead and talks about the upcoming WordPress 3.0 version and some of what will come with it.

There's typically a ton of hype surrounding new WordPress releases, and WordPress 3.0 certainly won't be short of people singing its praises. This upcoming release might even have more hype than usual because the sheer number of new features will be overwhelming. When WordPress 3.0 is released, it'll mark the release of several things I've been waiting for in the last couple of years. It'll be at a point where it can be molded to create any type of website.

He talks about what things will make this release stand out from some of the ones in the past and what features with come with it including custom post types, improved navigation menu features, built-in shortlinks, custom headers/backgrounds and and more standardized comment form.

If I were to dub this release anything it'd be WordPress: Custom.
Categories: Php, PHPDeveloper.org

Elliot Haughin's Blog: Building UTF8 Compatible CodeIgniter Applications

Thu, 2010-03-25 17:13

Elliot Haughin has written up a post for all of those developers out there either already using CodeIgniter or wanting to use it for your application - a look at making a UTF-8 compatible site with the help of a few custom libraries and form helpers.

UTF8 allows your site to represent characters other than those in the basic english alphabet. More often than not, your CodeIgniter Application will contain methods where users can enter their name. [...] This guide assumes you are reasonably competent in installing php extensions, adding config variables to your php.ini, and using MY_ CodeIgniter overloading. If you're not sure about any of these, please make sure you consult a professional.

You'll need to install the mbstring extension for PHP to be able to follow along with his example. He shows how to override the basic form functionality with custom functions to change the display of the form and how it handles the submitted information. He also looks at how to update the XML-RPC library that comes with the framework and the creation of a new helper to allow you to convert, check, compare and sort UTF-8 data.

Categories: Php, PHPDeveloper.org

Dave Gardner's Blog: Caching dependency-injected objects

Thu, 2010-03-25 16:49

Dave Gardner has posted about a method he uses to cache objects that have dependency injection needs in something like a memcached server.

The objects themselves have a number of injected dependencies. It includes using the PHP magic methods __sleep and __wakeup to manage serialisation. It also discusses mechanisms for re-injecting dependencies on wakeup via a method that maintains Inversion of Control (IoC).

He uses a user object based example that has an injection needed to load in the user's usage history. He includes the code to define the classes, create the objects via a dependency injection container and performing the sleep/wakeup actions with the dependencies coming out intact on the other side.

Categories: Php, PHPDeveloper.org

NETTUTS.com: MVC for Noobs

Thu, 2010-03-25 15:05

If you're relatively new to the framework world and haven't quite gotten your head around the whole Model/View/Controller way of doing things, you should check out this new tutorial from NETTUTS.com giving an overview of the method that's so popular among PHP frameworks these days.

Model-View-Controller (MVC) is probably one of the most quoted patterns in the web programming world in recent years. Anyone currently working in anything related to web application development will have heard or read the acronym hundreds of times. Today, we''ll clarify what MVC means, and why it has become so popular.

The look at each part of the MVC stack including what it's for and how it connects with the other two parts. An example is included - not in code but with an image showing the communication between the modules. They wrap up the post with a look at why using a MVC framework can help you be more productive. Their example uses CakePHP but the ideas could be applied to any MVC framework out there.

Categories: Php, PHPDeveloper.org

php|architect: TEKX Webcast "Mongo Scale!"

Thu, 2010-03-25 14:41

As a reminder, the latest in the TekX podcast series from php|architect is happening tomorrow - Kristina Chodorow will be presenting on MongoDB, a popular NoSQL database.

MongoDB is part of a new wave of persistent storage engines that make up the NoSQL movement. The most popular websites in the world are switching to or already use non-relational databases. Why? Scalability. This session will cover why, when, and how to use MongoDB: a fast, stable, easy-to-learn document database.

You can reserve your spot by registering on the go2meeting page for the event. Be sure to get in soon, though! The last webcast filled up and several people weren't able to make it in.

Categories: Php, PHPDeveloper.org

Phil Sturgeon's Blog: Modular Separation for CodeIgniter 2

Thu, 2010-03-25 13:33

In a new post to his blog Phil Sturgeon has posted about a patch he's created to give the pre-release CodeIgniter 2.0 version the ability to do some Modular Separation.

The fix was worked out a few hours after CodeIgniter 2.0 was released but I was hoping wiredesignz would incorporate and re-post. Sadly the man has other commitments to attend to, so I have released the patched version.

The patch includes two files - custom libraries to extend from for loading and routing in your CodeIgniter 2.0 application. For a better understanding of what this patch gives you, check out this thread on the CodeIgniter forums.

Categories: Php, PHPDeveloper.org

Giorgio Sironi's Blog: PHP in Action review

Wed, 2010-03-24 17:42

Giorgio Sironi has posted a review of a book he's recently gone through and shares some of his thoughts on the book's contents and how well he thinks it reaches its target audience - "PHP in Action".

It is very rare to encounter a book like this, which teaches object-oriented programming from a non naive point of view (How do I write those "classes?") in the PHP environment. PHP is still catching up with other languages in this field and many developers can only benefit from improving their modeling skills and design practices.

He talks about the topics the book focuses on including a bit of information on design pattern and test-driven development as well as some of the basics of really getting to know the PHP language. This isn't a beginner book, though - as Giorgio notes:

The average developer which has a deep understanding of the PHP technology will find this book useful to start upgrading his skills to the next level. [...] The level of the book is adequate for the intermediate coder, thus I found it easy to read. Nevertheless, it is a good panoramic of the PHP landscape in term of the transition to object-oriented programming.
Categories: Php, PHPDeveloper.org

Brian Swan's Blog: CRUD Operations with the OData SDK for PHP

Wed, 2010-03-24 16:17

Brian Swan continues his look at using the oData data feeds from PHP with this new look at creating some of the basic CRUD (create, read, update, delete) operations via the oData SDK for PHP.

This week I will go one step farther and look at how to perform CREATE, UPDATE, and DELETE operations (CRUD operations) with the generated classes. Of course, this means that I need access to a read-write service, so before writing PHP code for CRUD operations, I'll walk you through the steps for creating a service that implements the OData protocol.

He shows how to create the oData service (with a few screenshots), making the proxy classes for the connection and using methods like "AddObject", "UpdateObject" and "DeleteObject" to work directly with the data feed.

Categories: Php, PHPDeveloper.org

Brandon Savage's Blog: The Adventures Of Merging Propel With Zend Framework

Wed, 2010-03-24 15:12

In a new post to his blog Brandon Savage takes a quick loook at hos he integrated Propel into a Zend Framework app he'd built to replace an older site.

I wanted to use Zend Framework to practice on it, and to learn things I hadn't yet learned since I had yet to put an application into production; however, I didn't have any desire to rewrite my model, which was done in Propel. Propel has two things going for it already: the first is that Propel includes its own autoloader, meaning that I didn't have to try and force Propel into Zend Framework's file system structure. The second is that Propel is designed to let you put it's files anywhere you want with ease, so long as you update your include path properly.

He walks you through the process he followed to get things up and running - placement of the Propel libraries, working with the Propel configuration file and some pathing problems he finally figured out (by putting a model include directory into the path too).

Categories: Php, PHPDeveloper.org

Ibuildings techPortal: Book Review: Silverstripe - The Complete Guide to CMS Development

Wed, 2010-03-24 14:41

On the Ibuildings techPortal today there's a new review of a book focused on the SilverStripe content management system. In this review Hilary Boyce takes a comprehensive look at the book and its contents, getting into a bit of the specifics here and there.

The book has been produced through the collaboration between a developer of the product, Ingo Schommer who works for SilverStripe Ltd, and an experienced user, Steven Broshart who works for German online marketing agency Cyberpromote GmbH. It is a combination that works well. The book is convincingly authoritative but also down to earth; it is a practical guide from people who know what they are talking about and can explain it clearly citing realistic examples.

The book, first published in German and translated, covers everything you'll need to get started with this powerful CMS/framework. She talks about some of the content that stood out to her - the three chapters dealing with making an actual application based on SilverStripe. You can see more about the contents in this list on Wiley's site.

Categories: Php, PHPDeveloper.org

php|architect: Podcast #2010-04: Technosailor Moon

Wed, 2010-03-24 13:33

New from php|architect there's the latest episode of their podcast, episode #2010-04, an interview with Aaron Brazell (aka Technosailor).

This edition, which shall henceforth be referred to as the one in which the entire gang tries its best to make new friends across the PHP community(ies), features guest star Aaron Brazell as we talk about communities, WordPress and pimping one's products.

You can find out more about Aaron over on his site, technosailor.com. If you'd like to listen to this latest podcast, there's a few different way to enjoy it. You can either listen in-page, download the mp3 or subscribe to their feed and get this and other great episodes/news from php|architect.

Categories: Php, PHPDeveloper.org