Extending Router in config.neon
- Bill Lions
- Member | 47
The docs here → https://doc.nette.org/en/configuring
give the impression routes can be added by the config.neon
>
routing:
routes:
‘detail/<id>’: Admin:Home:default
‘<presenter>/<action>’: Front:Home:default
I have tried the following:
routing:
routes:
‘/user’: User:User:default
‘/user/admin’: User:User:admin
‘<module>/<presenter>/<action>’: User:User:default
The /user and the /user/admin urls result in this error:
Nette\Application\BadRequestException #404
Cannot load presenter ‘User’, class ‘App\Presenters\UserPresenter’ was not found
When the routes are added to the routerFactory, it all works fine.
Why does the config option not work?
- David Grudl
- Nette Core | 8228
You are probably combining your own router and the router in the configuration. Remove this from config:
services:
# router: App\Router\RouterFactory::createRouter
- Bill Lions
- Member | 47
David Grudl wrote:
You are probably combining your own router and the router in the configuration. Remove this from config:
services: # router: App\Router\RouterFactory::createRouter
Yep, and changed the namespace of my presenter to App\Presenters instead of
App and it works fine.
Thank you sir.