Where/how to store custom functions (or methods) in CakePHP

江枫思渺然 提交于 2019-12-11 06:54:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!