CodeIgniter Forums
Using Zend Framework components in CI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using Zend Framework components in CI (/showthread.php?tid=13936)

Pages: 1 2


Using Zend Framework components in CI - El Forum - 12-15-2008

[eluser]mihailt[/eluser]
To Canglan,

First of all, Zend_Loader is a part of the framework, so IMHO it's a better for your app to use it from a app design point of view.

Second, if you would check the manual a little bit more you would see that it has couple of methods.
The one we are using here is the loadClass - and it does not only include required file( via loadFile actually), but checks as well if the class exists. and if not it will throw an exception, so you have a possibility to do something about it should it fail.

And third and last for now, there is a possibility to assign autoload function to Zend_Loader, and free yourself from doing
Code:
$this->zend->load($classname);
before instantiation Zend classes you wish to work with.

Actually thinking about it, probably the better design solution would be removing this library, creating extended Zend_Loader class, and extending CI_Loader class to work with it.

Wink


Using Zend Framework components in CI - El Forum - 12-15-2008

[eluser]Phil Sturgeon[/eluser]
Excellent, loadClass() does what I was looking for. Might not be possible in raw PHP but their loader class allows you to pass the constructor an array of parameters.

Code:
Zend_Loader::loadClass('Container_Tree',
    array(
        '/home/production/mylib',
        '/home/production/myapp'
    )
);

This can easily be added to CI loader. Should it be $this->load->zend(? Not sure of the best implementation.

Also, not sure we need to use Zend Loader, we can do some basic checks and exception handling in the CI loader class.


Using Zend Framework components in CI - El Forum - 12-15-2008

[eluser]mihailt[/eluser]
second parameter for loadClass is a diriectory array to look in.


Using Zend Framework components in CI - El Forum - 12-15-2008

[eluser]Randy Casburn[/eluser]
[quote author="pyromaniac" date="1229353170"]You guys slightly missed the point ...[/quote]


Yes, I sure did. Thought you were writing your own sorry.


Using Zend Framework components in CI - El Forum - 12-15-2008

[eluser]Phil Sturgeon[/eluser]
[quote author="mihailt" date="1229365727"]second parameter for loadClass is a diriectory array to look in.[/quote]

Wasn't paying enough attention it seems. Well, pass on this project then. Smile