1

По URL вида http://127.0.0.128/user/user

Не получается отобразить страницу /view/aplication/user/user.phtml

Вероятно не так регистрирую новый контроллер в module.config.php?

return [
    'router' => [
        'routes' => [
            'home' => [
                'type' => Literal::class,
                'options' => [
                    'route'    => '/',
                    'defaults' => [
                        'controller' => Controller\IndexController::class,
                        'action'     => 'index',
                    ],
                ],
            ],
            'application' => [
                'type'    => Segment::class,
                'options' => [
                    'route'    => '/application[/:action]',
                    'defaults' => [
                        'controller' => Controller\IndexController::class,
                        'action'     => 'index',
                    ],
                ],
            ],                      
            'user' => [
                'type'    => Segment::class,
                'options' => [
                    'route'    => '/user[/:action]',
                    'defaults' => [
                        'controller' => Controller\UserController::class,
                        'action'     => 'index',
                    ],
                ],
            ],                      

        ],      
    ],
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,                        
            Controller\UserController::class => InvokableFactory::class                        
        ],
    ],  

UserController.php в папке Controller:

<?php
namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class UserController extends AbstractActionController{
    public function indexAction(){
        return new ViewModel();
    }    
    public function userAction(){
        return new ViewModel();
    }        
}

1 ответ 1

0

Достаточно было почистить от кэша папку data. Т.е. ошибки в коде нет

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.