I'm a beginner and I would like to know how can phalcon create user defined common function like getCurrentDateTime()?
|  | May '14 | 6 | 2747 | 0 | 
In the other PHP Frame like codeigniter, it will have library or helper. I can define my own functions by using library and helper. For instance, I can create a user function named generate_code(). I can use my function all over the application. If I want to modify the business logic of code generatioin, I just need to change one function. I am the beginner of Phalcon and I cannot find this kind of support. Could you please guide me? Thanks.
Andy,
You can use the DI container to store your class and then use it from wherever you want in your application. So for instance let's say that you have this class:
class Utils
{
    public function translate($string) {...}
    public function encode($string) {...}
    public function decode($string) {...}
}in your bootstrap you will register this as a service
$di->set(
    'utils',
    function () { 
        return new Utils();
    }
);Then from any controller you can do then:
$newValue = $this->utils->translate($oldValue);If you need to access the service in models you can use the
$utils = \Phalcon\Di::getDefault()->get('utils');@EleRam, you are probably not very familliar with PHP ? You can put the class wherever you want, and then register its namespace. This is all. Example:
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
    'Your\Class\Namespace'        => '/path/to/class.php',
));
$loader->register();@calinrada I'm not familiar with Phalcon. this is my first experience in frameworks.
Thank you :)