I'm trying to setup a ZF2 project (slightly different from the zf2skeleton) and I want to use composer to deal with all the autoloading, not only from the vendor ones (installed through composer) but also those modules I create.
For some reason, i can't get access to my Application module Index controller. I think its the autoloading that's not working... I just don't know what i might be doing wrong..
Thanks!
Files and data below:
This is my folder structure:
index.php
private
- modules
-- Aplication
--- src
----- Aplication
------- Controller
---------- IndexController.php
- vendor
-- zendframework
-- composer
-- autoload.php
- composer.json
- composer.phar
main.config.php
return array(
'modules' => array(
'Application',
),
'module_listener_options' => array(
'config_glob_paths' => array(
'private/config/autoload/{,*.}{global,local}.php',
),
'cache_dir' => realpath(dirname(__DIR__) . '/../../data/cache'),
'module_paths' => array(
realpath(__DIR__ . '/../module'),
realpath(__DIR__ . '/../vendor'),
),
),
);
index.php
include_once 'private/vendor/autoload.php';
$application = Zend\Mvc\Application::init(include 'private/config/main.config.php');
return $application;
composer.json
{
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*"
},
"autoload": {
"psr-0": {
"Application\\": "module/Application/src"
}
}
}
Application config
return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
);
IndexController
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
class IndexController extends AbstractActionController {
public function indexAction() {
die("app ok");
}
}