-- till <[email protected]> wrote
(on Thursday, 26 February 2009, 09:52 PM +0100):
> On Thu, Feb 26, 2009 at 9:19 PM, awkaiser
> <[email protected]> wrote:
> >
> > This message is intended for @weierophinney, but feel free to pitch in if
> > you
> > have a solution. :) This might be an easy one for you guys!
> >
> > The short story is that I'm giving Zend_Loader_Autoloader_Resource
> > (incubator) a spin and have run into some unexpected behavior. It seems to
> > load my classes correctly (my page will display with the expected
> > information from the database) but Zend_Loader complains with some warnings:
> >
> > Warning: Zend_Loader::include_once(Projects/Model/Projects.php)
> > [function.Zend-Loader-include-once]: failed to open stream: No such file or
> > directory in /[...]/library/Zend/Loader.php on line 83
> >
> > Warning: Zend_Loader::include_once() [function.include]: Failed opening
> > 'Projects/Model/Projects.php' for inclusion (include_path='[...]') in
> > /[...]/library/Zend/Loader.php on line 83
> >
> > Warning: Zend_Loader::include_once(Projects/DbTable/Projects.php)
> > [function.Zend-Loader-include-once]: failed to open stream: No such file or
> > directory in /[...]/library/Zend/Loader.php on line 83
> >
> > Warning: Zend_Loader::include_once() [function.include]: Failed opening
> > 'Projects/DbTable/Projects.php' for inclusion (include_path='[...]') in
> > /[...]/library/Zend/Loader.php on line 83
>
> Somewhat related and more a question for Matthew, but is the
> *autoloader* supposed to use include_once?
It's using include -- as it should be (look at line 83 of Zend_Loader,
as reported above, if you don't believe me; it reads "include $file;").
I'm not sure why it's being reported as "include_once".
We use include() because the _once variant has more of a performance
impact. Internally, we check first to see if the class_exists(), and
only if it doesn't do we attempt to include() it. And yes, I've profiled
and benchmarked both approaches. :)
> > So, it seems to be attempting to include the classes from my include path.
> > My assumption is that Zend_Loader_Autoloader_Resource should take care of
> > everything (like taking overriding the processing of namespaces in such a
> > way that the default Zend_Loader actions are never executed) and I shouldn't
> > need to touch my include_path.
> >
> > Is there something I need to do in my bootstrap prior to using ZLAR to avoid
> > that include conflict? Right now the bootstrap has nothing specific to ZLAR
> > and I'm just instantiating it in my modules' index controller init()
> > functions like so:
> >
> > $loader = new Zend_Loader_Autoloader_Resource(array(
> > 'namespace' => 'Projects',
> > 'basePath' => dirname(__FILE__) . '/..'
> > ));
> >
> > $loader->addResourceTypes(array(
> > 'Model' => array('path' => 'models', 'namespace' => 'Model'),
> > 'DbTable' => array('path' => 'models/DbTable', 'namespace' =>
> > 'DbTable')
> > ));
> >
> > ... where my directory structure is:
> >
> > /application
> > /modules (just showing one for illustration)
> > /projects
> > /controllers
> > IndexController.php
> > /forms
> > /models
> > /DbTable
> > Categories.php
> > Features.php
> > ProjectCategories.php
> > ProjectFeatures.php
> > Projects.php
> > ProjectsSimilar.php
> > Projects.php
> > /views
> >
> > Maybe I'm violating "best practices" for ZLAR, who knows. :) Hopefully there
> > is a quick fix!
>
> LGTM! :) I bet the module structure throws it off somehow, I don't
> know what dirname(__FILE__) in your example resolves to, e.g., is your
> "bootstrap" in root/app/modules/ or in /root/.
>
> Cheers,
> Till
>
--
Matthew Weier O'Phinney
Software Architect | [email protected]
Zend Framework | http://framework.zend.com/