N
N
Nikolai Gromov2017-04-07 06:21:42
Zend Framework
Nikolai Gromov, 2017-04-07 06:21:42

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',
                    ],
                ],
            ],
        ],
    ],

shop/module.config.php
'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',
                    ],
                ],

So this is when I display:
<div class="img-thumbnail">
        <img src="<?= $this->url('home', ['action'=>'file'], 
                                ['query'=>['name'=>$file]]); ?>">
</div>

I should have a picture, but instead the icon of the image, and the url of the image is
zblog.local/?name=logo.png
those. 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

1 answer(s)
S
Shirshov Alexander, 2017-04-21
@Keanor

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 question

Ask a Question

731 491 924 answers to any question