 | News Feed |
Sections
|
| feed this: |  |
ProDevTips Blog: Fluent Arrays and Strings in PHP
by Chris Cornutt June 23, 2008 @ 07:57:18
On the ProDevTips blog, Henrik has written up an extensive tutorial with plenty of code examples on working with something inspired by a few other languages - fluent arrays and strings.
I've been working some with jQuery and Ruby lately, as you might know they both have very neat fluent interfaces for writing short and easily understandable code. Especially Ruby's array and string handling should be something that can be done in PHP so I started googling. [...] It's probably very possible that what I'm looking for is already part of some PHP framework or such but I didn't want to spend more time looking than being productive.
Based on some Ruby examples, he defines a set of functions that can be use to create these fluent interfaces to the common PHP variable types (contained in a class for easy use). The entire source can be downloded here.
voice your opinion now!
fluent string array class source download tutorial
Zend Developer Zone: Fluent Interfaces in PHP
by Chris Cornutt December 20, 2006 @ 08:55:00
The Zend Developer Zone has posted a new article from editor of the dZone, Cal Evans, looking at using fluent interfaces in PHP.
Fluent Interfaces are not a new programming construct. However, PHP developers have not been able to use them until PHP 5. Now with PHP 5 and the ability to directly dereference an object, PHP developers can build objects using fluent interfaces.
He starts off with a look at what they are and how (and why) they can be used in an application. He includes code example to help show how you would create an interface (makeNormal).
The code and other information are pulled from a few sources:
Cal also mentions what he got into the fluent interfaces game for - creating a tag cloud with a fluent interface over the normal arguments/properties method.
voice your opinion now!
fluent interface mikenaberenzy martinfowler pauljones fluent interface mikenaberenzy martinfowler pauljones
Davey Shafik's Blog: Next Generation REST Web Services Client
by Chris Cornutt September 22, 2006 @ 07:25:38
In his latest post, Davey Shafik talks about a web service client that he's been working up for the Zend Framework, specifically dealing with the consuming and creation of REST services.
I am currently working on a ton of Web Services related things for the Zend Framework, one of my favorite, is the almost complete, Zend_Rest_Client. This is a replacement for Zend_Rest (as we're adding a server also).
Whilst it is almost impossible to emulate the PHP 5 SOAP extension, it is still possible to get a nice interface.
He gives some examples of its usage:
- creating a client with three lines of code
- showing off the "fluent API" of the component to make a REST request
- and a call normally, seperating the methods out into seperate lines
He also mentions that there's still a bit of work to be done, including returning the Zend_Rest_Server array responses back into normal PHP arrays.
voice your opinion now!
rest web service client zend framework fluent simple rest web service client zend framework fluent simple
Jonnay's Blog: Introducing BunnyRegex - easy regular expressions, and mini-languages inside of PHP.
by Chris Cornutt March 02, 2006 @ 06:52:20
On his blog today, Jonnay has posted information about a new library he's built up called "BunnyRegex", a way to make easy regular expressions and mini-languages inside of PHP.
Regular expressions are hard. They are hard to create, and even harder to read after the fact. Regular expressions, while quite powerful, are a blight upon readable code. There is no easy way to know that '/^d{4}/d{2}/d{2}$/' is a search for a string in the form of 'xxxx/xx/xx'. You have to know that ^ is the start of a line, d is a digit, / is / escaped, etc.
Granted, once you know regular expressions, that information is portable across which ever language you use, be it PHP, Perl, Javascript, whatever. But getting to that point is not easy, and even after you are there, the fact remains:Regular expressions are not human parseable. This is where BunnyRegex comes in.
He includes examples of the usage of the library (not as concise as a regex, but easier to read) and how you can also use it to create "fluent regular expressions". The library even allows you to do most of the normal things you would with a standard regex engine - match, grep, replace, and splitting data.
voice your opinion now!
php regular expression bunnyregex simple fluent human-parseable php regular expression bunnyregex simple fluent human-parseable
Tobias Schlitt's Blog: A sensible place for a fluent interface
by Chris Cornutt January 03, 2006 @ 11:52:41
On his blog today, Tobias Schlitt has his look at fluent interfaces, and it's place in the eZ components libraries.
The new buzz term "fluent interface" has been mentioned a lot in the PHP world recently, so I will not again explain, what a "fluent interface" is. Andi already mentioned, that this way of desining an API is quite good and can give you a really handy interface, but he also points out, that one should make very careful use of the technique.
Also I did not know the term "fluent interface" before, we realized, that we already used this in the eZ components, to be more exact, in our Database package, which gives you a quite good ammount of SQL abstraction.
He gives a brief example from their code, and explains how it works. The statement selects from a table "Person" where the age is greater than 15 and orders it by the "full_name" field, limit of 10 rows returned. With the "fluent interface" concept, that's pretty much how the statement "reads" as well...
voice your opinion now!
php fluent interface sensible place ez components php fluent interface sensible place ez components
|
Community Events
Don't see your event here? Let us know!
|