Welcome Guest, Not a member yet? Register   Sign In
Using Zend Framework components in CI
#11

[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
#12

[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.
#13

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

[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.
#15

[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




Theme © iAndrew 2016 - Forum software by © MyBB