7
votes

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
3

3 Answers

9
votes

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.

1
votes

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

0
votes

in module.config.php remove the ClassMapAutoLoader mapping, it should only have the StandardAutoloader as shown below;

public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
        ),
    );
}

This will solve the issue.