OK, I’m pretty new to this, and ploughing through all the tutorials and answered questions I can find. Unfortunately I haven’t been able to find a complete application.ini that works for me.
Somewhere I must have stuffed up – I can get the basic routing working OK, but as soon as I try and add a variable I can’t get it to work. So /guide-to works, but /guide-to/london gives the error “someplace is not specified”
I’m doing all the routing in application.ini. Here’s my file:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/views/layouts/"
resources.layout.layout = wrapper
resources.view = ""
resources.router.routes.home.route = "/stuff"
resources.router.routes.home.defaults.module = default
resources.router.routes.home.defaults.controller = index
resources.router.routes.home.defaults.action = index
resources.router.routes.guide-to.route = "/guide-to"
resources.router.routes.guide-to.defaults.controller = "destination"
resources.router.routes.guide-to.defaults.action = "guide-to"
resources.router.routes.place.route = "guide-to/:someplace"
resources.router.routes.place.defaults.controller = "destination"
resources.router.routes.place.defaults.action = "guide-to"
resources.router.routes.guides.route = "/guiderrrs"
resources.router.routes.guides.defaults.controller = destination
resources.router.routes.guides.defaults.action = guiderrrs
resources.router.routes.guidez.route = "/guidez"
resources.router.routes.guidez.defaults.controller = destination
resources.router.routes.guidez.defaults.action = guidez
pagination.item.count.per.page = 10
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Can anyone spot the problem? Or does anyone have a working application.ini they could share?
All contributions gratefully received!
You need to specify a default value for someplace variable. someplace is variable so you need to give it a default value. Otherwise it will default to undefine.
I think like this :
In my opinion it’s not a good idea to map your url to the exact names.
because url becomes really coupled with the application wich can change.
I rather prefer to use a generic router in my bootstrap. and then map my url to it. using this approach my routing system is the same as I start a new project.
Use seomthing like this in your bootstrap . it is even shorter than defining all the routes
because if things change you would need to change back
Lang is my own variable for internationalization suppor.