ZF-11708: Zend_Loader_Autoloader_Resource::autoload does include instead of include_once

Issue Type: Bug Created: 2011-08-30T11:41:30.000+0000 Last Updated: 2012-04-20T14:44:19.000+0000 Status: Open Fix version(s): Reporter: Wouter Tengeler (wouterten) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Loader

  • zf-crteam-review

Related issues: Attachments:


The autoload method returns include of a file. This results in duplicate inclusions when using a PHP 5.3 namespaced interface class. When I change the include to include_once, the problem is solved.

To autoload PHP namespaced model classes I use:

<pre class="highlight">
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    protected function _initAutoloader()
        $loader = function($className) {
            $zfClassName = str_replace('\\', '_', $className);
            if (!class_exists($className, false) && !class_exists($zfClassName, false)) {

        $autoloader = Zend_Loader_Autoloader::getInstance();
                // Scrum is set as appnamespace = "Scrum" within application.ini
        $autoloader->pushAutoloader($loader, 'Scrum\\');


Posted by Martin S. (zickedi) on 2012-01-03T17:23:50.000+0000

Same problem here. Following code is critical:

public function autoload($class)
    $classPath = $this->getClassPath($class);
    if (false !== $classPath) {
        return include $classPath;
    return false;

And still in trunk...

Posted by jeff sank (jsank) on 2012-04-19T20:36:19.000+0000

i'm getting, what i believe to be the same issue - after moving zend/doctrine to a new server i get a fatal 'cannot redeclare class' error after running 'class_exists' check on the class.

not sure what other details would be relevant

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.