News for hackers. Stuff that matters.
Re:The Micro PHP Manifesto's Missing Tenet by ericingram on Tuesday January 10, 2012 @02:14PM (#3448479)
I started using functions widely in an MVc framework. It began when Rails was released, and I thought, how could I copy the "helper" mechanism in a way that makes sense for PHP?

My answer was to use plain functions as helpers, at first because they could easily become Smarty modifiers, and later realized the function-only pattern worked really well across the whole app.

I write code like this...

# file: helpers/say_hello.php

    function say_hello ($params)
    {
        $to = $params['to'] ?: $params;
        return "Hello, {$to}!";
    }
Which is auto loaded by the framework and usable like this:

(PHP):

    echo say_hello('World');
(Smarty):

    {say_hello to="World"}
Re:The Micro PHP Manifesto's Missing Tenet by ericingram on Tuesday January 10, 2012 @02:20PM (#3448504)
Note: I purposely called it MVc vs. MVC. The controller is minimized in favor of native REST access to models/resources. If anyone is curious about this, I'll be writing about the new convention soon.