0

I have an application with some modules. One of them is CourseSearch. Now I want to add a further one, the SportsPartnerSearch. Since these two modules are very similar to each other, I simply "cloned" / copied the CourseSearch and replaced all "Course" with "SportsPartner" (in all variations: $course to $sportsPartner, course-...phtml to sports-partner-...phtml etc.), in order to edit the logic in the second step. Now I'm getting following errors:

Warning: require_once(/path/to/project/module/SportsPartnerSearch//src/CourseSearch/View/Helper/CourseSearchForm.php): failed to open stream: No such file or directory in /path/to/project/vendor/zendframework/zendframework/library/Zend/Loader/ClassMapAutoloader.php on line 140

Fatal error: require_once(): Failed opening required '/path/to/project/module/SportsPartnerSearch//src/CourseSearch/View/Helper/CourseSearchForm.php' (include_path='.:/usr/share/php:/usr/share/pear') in /path/to/project/vendor/zendframework/zendframework/library/Zend/Loader/ClassMapAutoloader.php on line 140

Why is the path to the file being built in such strange way: /path/to/project/module/SportsPartnerSearch//src/CourseSearch/View/Helper/CourseSearchForm.php? Where did I do a mistake?


Some additional information.

The class, that cannot be found because the wron path is CourseSearch\View\Helper\CourseSearchForm in the CourseSearch module. It can be found, when I deactivate the new module SportsPartnerSearch, that contains the class SportsPartnerSearch\View\Helper\SportsPartnerSearchForm.

The CourseSearchForm view helper is instanciated in the CourseSearchForm\Module

class Module {
    public function getViewHelperConfig() {
        return array(
            'factories' => array(
                'courseSearchForm' => function($serviceManager) {
                    $helper = new View\Helper\CourseSearchForm(array('render' => true, 'redirect' => false));
                    // ERROR. This code is not executed anymore.
                    $helper->setViewTemplate('course-search/course-search/course-search-form');
                    $courseSearchForm = $serviceManager->getServiceLocator()->get('CourseSearch\Form\CourseSearchForm');
                    $helper->setCourseSearchForm($courseSearchForm);
                    return $helper;
                }
            )
        );
    }
}

And called in the layout file:

echo $this->courseSearchForm();

The SportsPartnerSearch\View\Helper\SportsPartnerSearchForm is instanciated in the same way in the SportsPartnerSearch\Module#getViewHelperConfig() and is not called yet.

automatix
  • 14,018
  • 26
  • 105
  • 230

1 Answers1

1

Have you generated a classmap? Check the autoload_classmap.php file in both the CourseSearch and the SportsPartnerSearch modules. I guess you still have an old classmap lying around. I think the problem is hidden inside the classmap because of the error in the ClassMapAutoloader from Zend, and not the standard autoloader.

You can generate a new classmap with the classmap generator provided in ZF2 (assuming you load it via Composer) with:

cd module/SportsPartnerSearch
../../vendor/bin/classmap_generator.php

This will generate a new classmap file inside the SportsPartnerSearch module.

Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99
  • Thank you very much! It works! It also works now namespace based without generated classmaps. Yesterday I cleaned my `autoload_classmap.php` files and tried it without them, but the error was still occuring. Now I've generated the classmaps again (it worked) and cleaned the maps again and now it's also working namespace based. So, I think, yesterday I forgot to clean one classmap. – automatix Oct 04 '13 at 08:12