Cakephp 3 loading vendor files

只愿长相守 提交于 2019-12-05 02:23:06

问题


In cakephp 2 when I need a vendor or related class to be loaded globally, i was adding require or app use inside bootstrap.php ot core php.

In cakephp 3 where should I require vendor files ? I dont want to declare vendor require in every class and template file that I use my vendor files.

http://book.cakephp.org/3.0/en/core-libraries/app.html#loading-vendor-files


回答1:


Vendor files are 3rdparty files. You custom static utility classes are not vendor files but rather your app files. You can put them under src/Lib/. Just ensure to use proper namespace for the classes and add proper use statement wherever you need to use your class.

For e.g. if your lib class is src/Lib/FooBar.php then it should have classname App\Lib and the "use" statement would be use App\Lib\FooBar.



来源:https://stackoverflow.com/questions/31354954/cakephp-3-loading-vendor-files

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