I am setting zend framework 2 project as per provided documentation in Zend quick start
I have downloaded skeleton application, It displayed "welcome to zend framework" home page correctly. And as per suggested in documenation I have tried to access myproject.localhost/1234 url but it does not displayed 404 error within the project scope but 'Not found' page opened without navigation bar, css (ie. url rewritting not working). I do not have IIS installed on my machine only have wamp server, So idealy it should work.
Can anyone guide me for this error. I have created virtual host also
Because you're trying to resolve a not-configured route by requesting myproject.local/1234 so, if you want to pass 1234 as parameter to your index controller (home route), set that route begging from this line like follows:
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/[:myparam]',
'constraints' => array(
'id' => '\d*',
),
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
Now you can get myparam in in IndexController something like this:
public function indexAction()
{
$myparam = (int) $this->params()->fromRoute('myparam', 0);
var_dump($myparam); // Prints 123 on myproject.localhost/123 and 0 on myproject.localhost
exit; // Exit for just simply show the logic. Don't use exit in controller like this.
}