
Kod kontrolera:
<?php namespace Users\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class IndexController extends AbstractActionController { public function indexAction() { $view = new ViewModel(); return $view; } public function registerAction() { $view = new ViewModel(); $view->setTemplate('users/index/new-user'); return $view; } public function loginAction() { $view = new ViewModel(); $this->view->zmienna = 1; $view->setTemplate('users/index/login'); return $view; } }
Kod pliku module.config.php:
<?php /** * Zend Framework (http://framework.zend.com/) * * @link <a href="http://github.com/zendframework/ZendSkeletonApplication" target="_blank">http://github.com/zendframework/ZendSkeletonApplication</a> for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license <a href="http://framework.zend.com/license/new-bsd" target="_blank">http://framework.zend.com/license/new-bsd</a> New BSD License */ 'type' => 'Literal', 'route' => '/users', '__NAMESPACE__' => 'Users\Controller', 'controller' => 'Index', 'action' => 'index', ), ), ), 'type' => 'Zend\Mvc\Router\Http\Literal', 'route' => '/', '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 'type' => 'Literal', 'route' => '/application', '__NAMESPACE__' => 'Application\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'type' => 'Segment', 'route' => '/[:controller[/:action]]', 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), ), ), ), ), ), ), ), 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'translator' => 'MvcTranslator', ), ), 'locale' => 'en_US', 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'Application\Controller\Index' => 'Application\Controller\IndexController', 'Users\Controller\Index' => 'Users\Controller\IndexController', ), ), __DIR__ . '/../view', 'users' => __DIR__ . '/../view' ), ), // Placeholder for console routes ), ), ), );
Widoki to zwykły kod HTML.
Problem polega na tym, że przy wejściu na adres : localhost/users/index/login dostaję błąd:
Cytat
A 404 error occurred
Page not found.
The requested URL could not be matched by routing.
No Exception available
Page not found.
The requested URL could not be matched by routing.
No Exception available
Przy wejściu na localhost/users wszystko ładnie działa. Macie jakiś pomysł w czym może być przyczyna problemu?