Good morning,
I'm currently learning Zend 2 but already have experience in MVC. I installed the current zend2 skeleton application, which is reachable under http://learningzend.local/ on my local machine.
Now, I'm trying to understand Zends routing but I'cant reach /application/index/index. It returns 404.
Here is an excerpt from module.config.php. The only thing I changed was the type in the two latter routes, it was originally set to 'Literal' and 'Segment' without the path. The home route seems to work: when I change the action, the homepage disappears.
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
And few lines below
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
The controller is completely unchanged
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
}
I tried everything. Resetted the whole skeleton app to default but it did not change anything. Hope some Zend gurus can tell me whats wrong.
For completeness my VHOST entry
<VirtualHost *>
ServerName learningzend.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/learningzend.local/public/
AccessFileName .htaccess
<Directory /var/www/learningzend.local/public/>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>