ZF2 - autoloader classmap Fatal Error 'Map file provided does not exist'

arjay0601 picture arjay0601 · Nov 24, 2012 · Viewed 7.7k times · Source

I just started Learning Zend Framework but I am having problem with my modules. Please see the below error. I don't know what else to show you yet for further infomation. Please let me know what I need to show you to solve the problem.

Fatal error: Uncaught exception 'Zend\Loader\Exception\InvalidArgumentException

Fatal error: Uncaught exception
'Zend\Loader\Exception\InvalidArgumentException' with message 'Map
file provided does not exist. Map file: "C:\Program
Files\xampp\htdocs\zend_intro\module\Album/autoload_classmap.php"' in
C:\Program
Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Loader\ClassMapAutoloader.php:175
Stack trace: #0 C:\Program
Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Loader\ClassMapAutoloader.php(85):
Zend\Loader\ClassMapAutoloader->loadMapFromFile('C:\Program File...')
 #1 C:\Program Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Loader\ClassMapAutoloader.php(121):
Zend\Loader\ClassMapAutoloader->registerAutoloadMap('C:\Program
File...') #2 C:\Program
Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Loader\ClassMapAutoloader.php(64):
Zend\Loader\ClassMapAutoloader->registerAutoloadMaps(Array) #3
C:\Program
Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Lo
in C:\Program
Files\xampp\htdocs\zend_intro\vendor\zendframework\zendframework\library\Zend\Loader\ClassMapAutoloader.php
on line 175

Answer

Yes Barry picture Yes Barry · Nov 24, 2012

If you've copied example code from a module that actually used the autoload_classmap.php file, then you probably have something like this in your module.config.php file or somewhere in your Module.php file:

public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\ClassMapAutoloader' => array(  // THIS IS
            __DIR__ . '/autoload_classmap.php'      // THE PROBABLE
        ),                                          // CULPRIT
        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
            )
        )
    );
}

The solution? Either remove those lines of code - you are not required to have an autoloader classmap for each module - or actually create a classmap.