CakePHP - Where is the best place to put custom utility classes in my app structure?

别说谁变了你拦得住时间么 提交于 2019-12-07 13:31:01

问题


I am making utility classes that will provide general methods for helping manipulate strings. I may also want one for arrays, math functions, etc. Should these be components? Vendors? Could I maybe make these into some sort of vendor package?


回答1:


If they're general standalone libraries not tied to any particular step of the request cycle (controller, model, view), put them in app/libs/. You can import them using App::import('Lib', 'Foo').

Personally I have two or three handy array functions I always use defined in bootstrap.php, which is another place to put a small amount of global stuff.



来源:https://stackoverflow.com/questions/7307083/cakephp-where-is-the-best-place-to-put-custom-utility-classes-in-my-app-struct

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