PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] Cakephp 3 loading vendor files

 January 18, 2022     cakephp, cakephp-3.0, php, vendor     No comments   

Issue

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


Solution

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.



Answered By - ADmad
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing