问题
i need to have several functions in cakephp application (for some regular expression matching).
which is best way to store them, so i can access to them in every controller action?
tnx in adv!
回答1:
I would recommend you store the functions in the AppController
class. All of your controller classes inherit from this controller.
Also create the app_controller.php
file in the root folder of your application if you have not already.
回答2:
Or, if the actions aren't typical controller actions - you could store them in either a component (available to controllers) then include the component in your AppController.. or you could put the file in the vendors folder and use App::import to load the file into the bootstrap.php
来源:https://stackoverflow.com/questions/6074827/where-how-to-store-custom-functions-or-methods-in-cakephp