What’s the downside of not using a php route file?

Asked

Viewed 67 times

1

In several frameworks it is necessary to set a route in the system, as in the example below.

Route::get('MeuController/MinhaAction', function ($name) { // })

However, I would like to know what happens working as follows without having a route file defined.

In case, when accessing the site, my code would check if there is the file Meucontroller. If it exists, it instantiates the class Meucontroller. After instantiated, check for action Minhaaction, if this is true it would display the contents of that particular controller, if it does not exist it would report an error page.

Anyway, in practice this works normally and is widely used, but frameworks don’t work that way. Does it affect something? In which situations I could face problems in my system?

  • It depends a lot on the framework, some may not even work without route, such as Laravel, others end up disabling routes like Lazyphp. In theory the definition of routes would be to tell the system that links will be recognized and executed, also in theory, a route even existing but not defined as a route could not be accessed. But it can vary between framework.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.