Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 201
arjay0601 Avatar asked Nov 24 '12 10:11

arjay0601


2 Answers

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.

like image 114
Yes Barry Avatar answered Sep 19 '22 15:09

Yes Barry


Create a file called autoload_classmap.php under zend_intro/module/Album and include this line of code:

return array();

Check this on the documentation for more details Autoloading files

like image 38
waweru Avatar answered Sep 20 '22 15:09

waweru