0

I am trying to install Zend2 Framework module for mobile detection. Module is called Mobile Detect. I am following instructions given on that page, so i have cloned Mobile-Detect and the entire project from first link in vendor directory via git shell. I have added 'Neilime\MobileDetect'in application.config.php file and it shows me this error:

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Neilime\MobileDetect) could not be initialized.' in 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:144 Stack trace: #0 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(85): Zend\ModuleManager\ModuleManager->loadModule('Neilime\MobileD...') #1 
[internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent)) #2 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(464): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent)) #3 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL) #4 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\libra in 
D:\xampp\htdocs\zend2test\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 144
Harish Singh
  • 3,359
  • 5
  • 24
  • 39
user2406735
  • 247
  • 1
  • 6
  • 21

3 Answers3

1

I'd recommend using the composer installation method given in the docs instead.

If you really want to stick with git clone, try:

git clone git@github.com:neilime/zf2-mobile-detect.git Neilime/MobileDetect

from the vendor folder instead, which should clone it to the correct path.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • Thank you for your answer, this seems to work. I'll test it more now. – user2406735 Nov 20 '13 at 16:08
  • Could you please clarify what exactly does this do? This doesnt show error i described, but when i try to retreve an object it gives me this error: Class 'Mobile_Detect' not found in D:\xampp\htdocs\zend2test\vendor\Neilime\MobileDetect\src\MobileDetect\factory\MobileDetectFactory.php on line 10 as if i do not have Mobile_Detect.php library – user2406735 Nov 20 '13 at 16:57
0

The error means that the module cannot be found. This is probably an autoloading issue.

See the following question to see how to add the correct autoload config. https://stackoverflow.com/a/14980942/902466

In your case it'll be something like the following edit in init_autoloader.php:

Zend\Loader\AutoloaderFactory::factory(array(
    'Zend\Loader\StandardAutoloader' => array(
        'autoregister_zf' => true,
        'namespaces' => array(
            'Neilime\MobileDetect'   => __DIR__ . '/vendor/neilime/zf2-mobile-detect',
        ),
    ),
));

Edit: Obsiously using Composer would be the best idea since it will create the autoload configuration for you.

Community
  • 1
  • 1
Lauren Zonneveld
  • 683
  • 5
  • 15
0

I had a similar problem. The fix was a case issue:

Make sure your **M**odule.php file is written with a capital M otherwise the file may not be found. This took me a day to bug test so I really hope I save someone the same trouble!

HappyCoder
  • 5,985
  • 6
  • 42
  • 73