Sharing technology, ideas, insights!
Call: +91 710 466 0336         Email:


Help! vendor() is deprecated.

No, I don’t need help – I am the one providing it 🙂

Use of vendor() function to load third party libs in CakePHP has been deprecated for some time now… It has been replaced with the more generic App::import() the usage is simple

And it works fine…. now now! I wouldn’t write a blog entry for this trivial a thing even though I do need the traffic. Hey! anyone who blogs and says she does not need the traffic is a liar, but I digress here.

You soon run into trouble with the above syntax when you have a file which has a underscore in its name eg: if you have file_name.php then

does not work. You have to write

Still no big deal but the above code stops dead in its tracks if you have a vendor file name File_Name.php or worse if the vendor files are to be inside sub directories

Damn it! why can’t we enforce all the other developers to name their files properly? After all CakePHP is…
because my dear, we live in a real world and thankfully in real world there are solutions. The syntax to use is

In my case I ended up with

It may be noted that App::import() returns true on success which you can use to check successful loading of our vendor file.

Well, it is an entirely different matter than Sparkline class has a base class called very imaginatively “Object” and I was no better off in the end….

P.S. Thanks everyone for dropping by and increasing traffic and yes I did add this to but you would have never known if I had not said so.

About the Author

Dr. Tarique Sani is a pediatrician and forensic expert by education. He is a PHP programmer of 'wrote the book' caliber and has to his credit several very popular open source as well as commercial PHP projects. He leads a team of dynamic programmers at SANIsoft who have in-depth understanding of Web scalability, development tools and usability practices with strong developmental skills in PHP, MySQL/PostgreSQL, HTML, Javascript, and Linux/Apache

One comment

  1. Pingback: SaniSoft Blog: Help! vendor() is deprecated. | Development Blog With Code Updates :

Leave a Reply