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.
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.
Comments
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
Which is auto loaded by the framework and usable like this:(PHP):
(Smarty):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.