0

I am unable to install the ZfcUser / ZfcBase modules into the ZF2 Skeleton Application. (Ubuntu 12.10 server, Apache, PHP5.4.6)

1) Download and unzip the ZF2 skeleton application

2) Download and unzip ZF2 library into /vendor/ZF2

At this point, the skeleton application works fine.

3) Download and unzip ZfcBase and ZfcUser into /vendor/ (e.g. so that I have /vendor/ZfcXxxx/Module.php)

4) Edit config/application.config.php to include the two new modules

<?php
return array(
    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Application',
        'ZfcBase',
        'ZfcUser',
    ),

I now get

Fatal error:  Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcBase) could not be initialized.' in /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php:144
Stack trace:
#0 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php(85): Zend\ModuleManager\ModuleManager->loadModule('ZfcBase')
#1 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#2 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/EventManager/EventManager.php(464): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#3 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/EventManager/EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL)
#4 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php(104): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleMan in /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php on line 144

Presumably I'm missing some autoloading config...

fisharebest
  • 1,300
  • 10
  • 16

2 Answers2

0

Use composer.phar is pretty useful.

php composer.phar self-update
php composer.phar install

Anyway check your "autoload_classmap.php" and verify the add of ZfcBase.

Remi Thomas
  • 1,528
  • 1
  • 15
  • 25
0

I'm not using composer (for various reasons). This missing config to tell the application to load the module's autoload_classmap.php files is simply this.

Zend\Loader\AutoloaderFactory::factory([
    'Zend\Loader\StandardAutoloader' => [
        'autoregister_zf' => true
    ],
    'Zend\Loader\ClassMapAutoloader' => [
        __DIR__ . '/../vendor/ZfcBase/autoload_classmap.php',
        __DIR__ . '/../vendor/ZfcUser/autoload_classmap.php',
    ],
]);
fisharebest
  • 1,300
  • 10
  • 16
  • Composer creates it's own `autoload_classmap` so there is absolutely no need to use the ones provided by the Modules. Composer creates ONE Classmap for ALL Modules you manage via composer. – Sam Apr 01 '13 at 00:34
  • 1
    Additionally to what said by @Sam, consider that you shouldn't *ever* think about the internal structure of a module. Instead, adjust the `module_paths` option in your `config/application.config.php`, since the module should provide its own autoloading – Ocramius Apr 01 '13 at 06:23
  • @Sam/Ocramius. I'm not using composer. Are you saying that if I want to use a third-party module, then I MUST use composer? Is there no (acceptable) way to use/configure third-party modules without it? – fisharebest Apr 01 '13 at 09:45
  • Of course you can use those Modules without composer. We only suggest using it, because composer is like THE tool to get to know currently. The answer that you've been looking for has been pointed out by Ocramius - the most likely scenario was the missing `/vendor` path inside your `module_paths` configuration – Sam Apr 02 '13 at 05:27