Answer the question
In order to leave comments, you need to log in
Can't figure out routes?
In zend I have several modules, each has a configuration file with routes to the controllers that are in these files. I'm interested in the application and shop modules. Here are their configs:
application/module.config.php
return [
'router' => [
'routes' => [
'home' => [
'type' => Literal::class,
'options' => [
'route' => '/',
'defaults' => [
'controller' => Shop\Controller\IndexController::class,
'action' => 'index',
],
],
],
'application' => [
'type' => Segment::class,
'options' => [
'route' => '/application[/:action]',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
],
],
'router' => [
'routes' => [
'shop' => [
'type' => Segment::class,
'options' => [
// Change this to something specific to your module
'route' => '[/:action][/:id]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
<div class="img-thumbnail">
<img src="<?= $this->url('home', ['action'=>'file'],
['query'=>['name'=>$file]]); ?>">
</div>
zblog.local/?name=logo.pngthose. he does not see the action that should display it on the screen, tell me what is wrong with the route in ?
Answer the question
In order to leave comments, you need to log in
the home route is literal, it does not accept action and controller parameters, use the application route for this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question