Why not work out the controller in ZF3?

0 like 0 dislike
32 views
Hi all. Faced with the following situation. Created a standard skeleton of the third Zend via composer. Out of the box there is a prepared index of the controller. When working with him, that's totally fine, but when trying to create my own controller problems arise. Error as such crashes and even the template is displayed, but the logic of the controller is somehow dead. Even tried to register the die to the controller, and even he fails. Although in the index controller it works.

With regards to the actions undertaken to register a new controller and route to it.

The configs:
'blog' => [ 'type' => Literal::class, 'options' => [ 'route' => '/test', 'defaults' => [ 'controller' => Controller\\BlogController::class, 'action' => 'index', ], ], ],


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


The controller itself:
<?phpnamespace Application\\Controller;use Zend\\Mvc\\Controller\\AbstractActionController;use Zend\\View\\Model\\ViewModel;class BlogController extends AbstractActionController{public function index(){return ViewModel(['var' => 'variable value' ]); } }


What is interesting is the fact that even if the controller method has an empty body, then the template get displayed. But if you enter into the controller any logic, it somehow passes by. Someone faced with such problem? I may be a pitfall in the documentation I missed?
by | 32 views

1 Answer

0 like 0 dislike
Action methods in the controller must end in Action
In your case:
public function indexAction()
by

Related questions

0 like 0 dislike
1 answer
asked Jun 4, 2019 by glebvvs
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
32,706 users