I want to use a function in all models class (in project folder and in plugins folder).
Where should I declare it?
Depending on what your function does, you can create a file in the lib
folder and then call it from every where in your app. This is useful in a Symfony project to define common functions (like a toolbox).
For example, in the Jobeet tutorial, they define a method called slugify
in /lib/Jobeet.class.php
(be sure to name the file with .class.php
at the end so Symfony will automatically load it). Then, you can call Jobeet::slugify()
every where in your app/model/plugin/view.