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.