Route Should Throw Undefined Method Exception

I am studying luminas mvc. MVC should always be developer friendly. Inside my module.config.php file I have defined hello route like below

 'hello' => [
                'type' => Segment::class,
                'options' => [
                    'route' => '/hello',
                    'defaults' => [
                        'controller' => Controller\IndexController::class,
                        'action' => 'hellod',
                    ],
                ],
            ],

In action key I have misspelled hellod instead of hello. So, now it should throw exception as method hellod is not defined or method undefined hellod in browser as error. Instead it’s showing 404 not found.

But according to route file I have hello route, that means it’s not 404. It’s status code should be 50.*; I request to modify this

Hello and welcome to our forums! :smiley:

This is the documented behaviour:

  • The “action” parameter is converted to a camelCased format and appended with the word “Action” to create a method name. As examples: “foo” maps to fooAction, “foo-bar” or “foo.bar” or “foo_bar” to fooBarAction. The controller then checks to see if that method exists. If not, the notFoundAction() method is invoked; otherwise, the discovered method is called.
2 Likes

If the action is defined as a URL segment, then a 404 error must be thrown if the target does not exist.

Please compare with Getting Started tutorial:

'route' => '/album[/:action[/:id]]',
1 Like

Thanks for reply. I will try again