DevShed: Using the Observer Design Pattern with Static Data in PHP 5
626700
DevShed continues their look at handling static data in a dynamic application with the final part of the series - using the observer design pattern to handle the insertion of the static information.   I'll show you how to use a static property, along with the programmatic model dictated by the observer pattern, to implement an expandable data validation system. This task might have an immediate application in a real situation.   They show how to handle user information (as defined as properties in the creation of the user objects) and pushing that data back out into the page. The observer pattern comes into play when they go to validate the user information checking to see if it's all alphabetical, numeric or an email address.
317911
DevShed takes a look at another of the design patterns in a new series starting with this new tutorial - a look at the implementation of Adapter objects in PHP.   You may have already encountered situations in coding PHP applications in which you would like to use inheritance, but could not for one reason or another. Fortunately, there is an alternative for these situations that can help you achieve the same result. In this first article in a two-part series, you'll learn about the adapter pattern.   They start off with the basics of the Adapter pattern and move quickly into the first definition of a class using them - a directory processor. Once that's built, they show how it all works with a more practical example.
475410
On the SitePoint PHP Blog today Troels Knak-Nielsen asks th3e question "what's so bad about the singleton?" For all of its advantages, is there a darker side of the design pattern when it pertains to global variables.   As I have often taken this stance myself, I found it reasonable that I should be able to argue for it, so I'll try to give an explanation. This is also in part a follow-up on my post from last week, in which I present a way to avoid global symbols, without spending much time on why.   He talks about what they are and how they're commonly used - sometimes with some unpleasant side effects because of their use of globals.
197002
On the SitePoint PHP blog today, Troels Knak-Nielsen has written up an article that talks about dependencies in your applications - those little interconnections your code relies on to do more with less.   In lack of better words, I'll call this compositional programming style. It's a style which is usually more prevalent with experienced programmers. [...] There is, however, a dark side to composition - dependencies.   He starts with a definition to bring everyone up to a level field then moves on to how their used (through a "global symbol" or directly passed in) and how they can "leak" if you're not careful.    To help protect you and your code from any kind of damage down the line, Troels suggests making a container to keep objects where they need to be. He even includes an example with namespace support to make things even easier down the road.
377236
In a new post to his blog, Sebastian Bergmann mentions a new effort he's undertaken - the porting of the Hamcrest library of matcher objects to PHP.   I have begun to port Hamcrest, which provides a library of matcher objects (also known as constraints or predicates) allowing "match" rules to be defined declaratively, to be used in other frameworks. Typical scenarios include testing frameworks, mocking libraries and UI validation rules, to PHP.   The hamcrest-php project compliments other current hamcrest-related projects and his ultimate goal is to make it available to the PHPUnit testing community (as well as with the PHPMock effort).
649335
Michael Kimsal has posted some more thoughts on what he calls the "sad state of PHP development" pointing out some of the practices of the PHP group surrounding the development of the language.   Every few months there's a release, whether large or small, which introduces new features and bug fixes. However, with every release also comes fears of tiny, sometimes undocumented, changes that break existing code, and often for no solid reason other than someone with commit access decided they liked the 'new' way better than the old way.   He points out a specific example, get_object_vars and how its return values were changed in an earlier release as well as the update to glob made recently to change its return types.    In his opinion:   No changes should be made to the PHP core without an issue being opened, either in the 'bug' tracker or some other issues tracker.   Be sure to check out the comments for other great opinions on the topic.
624249
On the Zend Developer Zone, there's a new post pointing to the second part of their look at the Manning Publishing book "PHP in Action".   If you've been anxiously awaiting part two of this series then your wait is over. Here's a short introduction to the section part of this series written by the author of the book, Dagfinn Reiersol. I had the privilege of meeting Dagfinn at phpuk last week. Below the introduction is the link I know youâve been waiting for.   The new PDF they link to focus on two different patterns - the Decorator (a wrapper class) pattern and the Null Object (an object that works like the others but does nothing behind the scenes) pattern.
692223
Jim Plush has posted an offifical release announcement about his latest contribution to the PHP community - a debugging tool combining PHP (through the myBIC framework) and the Firefox FireBug extension.   I put together a couple pieces of technology to give the PHP community a debugger/profiler that should make life easier in the "web2.0" world. Are you tired of echo'ing print statements in your ajax calls? Writing to log files? Firing up big ol debuggers just to see what the value of some array is? Well look no further than the new MyBic PHP Debugger.   The tool is a smaller part of his larger MyBIC framework and can do things like writing log files, echo information back out to the screen, and communicate information back out to the Firefox user. There is a standalone version of FireBug that will be posted for those that don't want to have to install an entire framework to use it.   Keep an eye out (here and on his blog) for the links to the release when it's posted. In the meantime, you can check out a screencast [mov] of the package in action or just the screenshots in the blog entry.
320871
In a new post, Lukas Smith mentions (among other things) an upcoming webcast via the folks over at php|architect covering the best practices of using the opcode cache in your applications.    oin us as we host PHP internals developer, Stas Malyshev (Zend) with a presentation on optimizing your use of PHP opcode caching software, be it APC, Zend Platform, or another.   This talk will cover techniques that you can use to squeeze the most performance out of your cache, such as avoiding runtime includes and conditional class declaration.    Register soon because the event happens this Friday (March 16th, 2007) and there is no cost to attend - but you do have to sign up.
444294
DevShed launches a new tutorial series today with this new article, an introductory look at using the PDO objects in PHP5.   As you may have seen at first glance, the PDO extension looks really useful in certain situations. In this three-part series, I'm going to introduce its most important features, by accompanying the corresponding theoretical concepts with numerous hands-on examples, in this way facilitating the respective learning curve.   They start the series off with a look at using the extension and connecting to a resource (in their case, a MySQL database). Then, it's on to performing queries and grabbing the last inserted IDs for the rows your script just put in.
548706
The Zend Developer Zone has posted a review of Packt Publishing's "Learning PHP Data Objects" book writen up by Akash Mehta.   In Learning PHP Data Objects, the author Dennis Popel examines this new [database access] system and explains how to begin using PDO in development as a replacement for typical database drivers. The book is an excellent introduction to the data abstraction layer and also provides essential insight into the inner workings of database interaction with PHP.   Akash talks briefly about the history of PDO and what it can be used for first, then gets into the contents of the book (things like the intro chapters and the quality of the writing). The thing he thinks makes the bok stand out, though, is the examples and sample code that reflect both simple methods and more complex issues PDO developers might run into.
431197
DevShed continues its look at the Decorator pattern with this new article today talking about working with MySQL result sets inside of the structure of the Decorator pattern.   Definitely, the pattern in question can be used for generating different types of outputs (or views) based on a returned result set, by using a few decorator classes that I'll define in the course of this tutorial. Hopefully, when you finish reading these lines, you should have a clear idea of how to include decorator classes in your object-based PHP applications.   They start off by showing how they're going to handle the MySQL result sets normally with a class and how to use that class in an example. Finally, they tie all of that in with the Decorator pattern, creating multiple Decorator classes to handle the various MySQL result set types.
177344
P&aacute;draic Brady is back today with the latest installment (part 5!) of his look at complex views in the Zend Framework. This time, her focuses on something called the Two-Step Pattern - a pattern similar to the Layouts pattern.   Part 5 of our series takes a small time-out from approaching a Composite View solution to reusable Views to take a peek at a simpler approach useful for simpler types of web applications. As we've discussed previously Composite Views allow the nesting of reusable View elements, effectively building a View based on a hierarchy of Views. But often there are simpler solutions to simpler problems. One such solution is the Two-Step View pattern, sometimes called Layouts if implemented in a specific way (as we do below!).   He gives the example of a simple website that needs a header and footer on every page. Rather than having to duplicate the header/footer calls across all of the pages, the Layout (Step-Two) pattern defines a single template that contains the header and footer but also uses a "main" area where the content is dynamically inserted.   He includes a full code example to help illustrate the point - a class, Zps_View, that is fed the path to the layouts and the layout files to use before rendering.
104778
Latest PHPClasses.org Releases:Multi-Dimensional Array HandlerMySQL2JSONBBCode ParsersphpcompilerProcessingExponsor ModSimplePagingweb20vnRouterSStatusMagic ArraysqlExecmyAltCaptchaDynamic Methodpreg_magic
334117
Sean Coates has posted a new article today about one of the features that will be included in the next major release of PHP (5.3) - late static bindings.   Late Static Binding (LSB) is a topic that's been brought up numerous times in the past three years in various PHP development discussion circles (and we're finally getting it in PHP 5.3)Ã¢Â"but what does it really do, and why should you care? Here's a simple practical example of how it can greatly simplify your code's design.   He shows its usefulness in an example of how it works, letting classes/objects access static methods, constants and properties of inherited classes (besides their own). His example (using beer, of course) shows how an extended class (Ale) can reference the constant (NAME) in the parent class (Beer). Thanks to a new keyword in PHP 5.3 - "static::" - helps define the difference even clearer.   Check out the rest of the article for a more practical usage too.
653298
In the last part of this series, you'll learn how to build a declarative component for an application with a list of customers which is populated from a server-side data handler using AJAX. By David Johnson, Alexei White, and Andre Charland. 0910
152445
Latest PHPClasses.org Releases:Flash MessagesRSS and Atom Feeds Processing APImabp::tagCloudUltimate MySQLerror_managerSingly Linked ListChinese Encode ConvertphpSortableASCII Art GeneratorPSPLMultiselectNiftyCubeAmazon ECS Webservicesimple Email ClassPHPDance