P4A 3: the first PHP framework with chain effect :-)

We kept this feature secret ’till now… let’s unveil the power of P4A 3 chainability:
working with P4A_DB_Source and chainability

This feature is already available for every P4A 3 component. It is inspired by the jQuery chainability and for the first time (AFAIK) comes to a PHP framework. I’m sure it will revolution the way everyone of us writes code, producing cleaner and much more readable code.

What did you say? Do you want a P4A 3 preview release? humm let me think… can you wait ’till monday? :-)

UPDATE: before writing this post I haven’t checked everyone of the 100,000 PHP frameworks out there thus I’m not sure P4A is the real first, the title is just a nice claim for a nice feature, nothing more. :)

10 thoughts on “P4A 3: the first PHP framework with chain effect :-)

  1. Pingback: Huston, we landed on the moon and it’s full of coders, P4A 3 must be released! @ Fabrizio Balliano's blog

  2. CriticJohn

    This is nice! :-) :-)
    Years ago, when i wrote code in Java, this was the best thing about it –
    foo = myObj.getThis().doThat().finallyThis().toString().Tokenize().getFirst();

    and so on.

    Somewhere down the line, with all the xml config files and the elaborate directory structures, J2EE lost its way among coders without huge biceps and triceps.
    You’re bringing back the good things in Java to PHP, albeit via inspiration from jQuery.

    Thank you! :-)

    Other interesting things can be found on the blog of Rob Rohan where he explains a simple idea behind “Simple MVC ASP”.

    It might look a toy before P4A, but the simplicity angle is VERY important.
    The code is released in public domain, so taking a concept from there isn’t going to rub anyone the wrong way :-)

    Now all we need is Ruby-style “5.times”…. Iterators, simulated by a global function or class.

    Maybe o(5)->times(‘callback_fn_name’) … ?
    (‘o’ is short for ‘object’ like h() or $() in Prototype.js)

    Another really useful addition to this code-simplifcation goal is the classic ASP structure “With … End With” :

    With obj do
    .count = 5
    .max = 10
    .min = 1
    .name = “foobar”
    End with

    Which might mean something like this:

    $this->setCount(5)
    ->setMax(10)
    ->setMin(1)
    ->setName(‘foobar’)
    ;
    //each of setCount(), setMax(), etc. returns $this.

    So, mutiple “$this->” are removed so that code looks less redundant.

    Right now, there is so much of :
    $this->foobar->do_something($abcd);
    $this->foobar->do_something_else($efgh);
    $this->foobar->do_something($ijkl);
    $this->foobar->do_something($mnop);
    ————————
    With .. End With

    What say? makes sense?

  3. Fabrizio Balliano Post author

    @CriticJohn: thank you for your suggestions, I’ll take a look at them but I can anticipate that some of them are quite difficult to implement and… actually some of them make me think “better to use ruby instead” because creating wrap-around things for unsupported PHP core constructor could lead to very tricky results.

    anyway, we’ll talk about those after the 3.0 release, we still have a lot of work to do :-)))

  4. joshdavey

    First php framework with chain effect? Doesn’t cake already do this as long as you’re using PHP5? I’m pretty sure Zend allows this for many of their classes and my own framework has been using method chaining for it’s activeRecord class for ages.

  5. Fabrizio Balliano Post author

    @joshdavey: post updated with a small note, anyway:
    – before writing the title I googled for info about other frameworks but nothing significant was found
    – googling for “cakephp chainability” does not return any significant result
    – I thought that title was just a nice claim for a nice feature and it’s not meant to be some kind of supremacy declaration I don’t really care about
    – in your framework I can’t find any “return $this” thus you’re not supporting chainability
    – using PHP5 does not mean you support chainability, if you don’t return $this on every method you’re not supporting chainability
    – Zend Framework does not support chainability, sorry

    I wrote this long comment not because I felt I had to justify myself but because there are too many unuseful wars within the free software environment which should be avoided.

Leave a Reply

Your email address will not be published. Required fields are marked *