I've been following this guide (http://socialsemanticweb.blogspot.com.au/2012/11/zend-framework-2-create-custom-library.html) but I can't get Zend to see my library (error message below).
Any ideas what could be wrong? thanks
my folder structure
my MyLibraryController.php
<?php
namespace MyLibrary\Mvc\Controller;
use Zend\Mvc\Controller\AbstractActionController;
class MyLibraryController extends AbstractActionController {
public function __construct() {
}
public function doSomething() {
//instantiate your model here and return result
$result = "test";
return $result;
}
}
my autoload_namespaces.php (inside vendor\composer)
<?php
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Zend\\' => $vendorDir . '/zendframework/zendframework/library/',
'ZendTest\\' => $vendorDir . '/zendframework/zendframework/tests/',
'Symfony\\Component\\Console\\' => $vendorDir . '/symfony/console/',
'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib/',
'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/',
'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/',
'DoctrineORMModule\\' => $vendorDir . '/doctrine/doctrine-orm-module/src/',
'DoctrineORMModuleTest\\' => $vendorDir . '/doctrine/doctrine-orm-module/tests/',
'DoctrineModule\\' => $vendorDir . '/doctrine/doctrine-module/src/',
'DoctrineModuleTest\\' => $vendorDir . '/doctrine/doctrine-module/tests/',
'MyLibrary\\' => $vendorDir . '/MyLibrary/library/',
);
my application.config.php (I've only added the MyLibrary entry. I've tried with and without it)
<?php
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'Application',
'DoctrineModule',
'DoctrineORMModule',
'Directory',
'Helpers',
'MyLibrary',
error message without adding MyLibrary module in application.config.php
Fatal error: Class 'Directory\Controller\MyLibaryController' not found in D:\work\eclipse\htdocs\directory\module\Directory\src\Directory\Controller\DirectoryController.php on line 17
error message with MyLibrary module entry in application.config.php
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (MyLibrary) could not be initialized.' in D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:175 Stack trace: #0 D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(149): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent)) #1 D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(90): Zend\ModuleManager\ModuleManager->loadModule('MyLibrary') #2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent)) #3 D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent)) #4 D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library in D:\work\eclipse\htdocs\directory\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 175