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
-
App::import('vendor', 'filename');
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
-
App::import('vendor', 'file_name');
does not work. You have to write
-
App::import('vendor', 'fileName');
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 http://book.cakephp.org/ but you would have never known if I had not said so.
About this entry
You’re currently reading “ Help! vendor() is deprecated. ,” an entry on SANIsoft – PHP for E Biz
- Published:
- 5.10.08 / 3:39pm
- Category:
- CakePHP
- Author:
- Tarique Sani
1 Comment
Jump to comment form | comments rss | trackback uri