-
Notifications
You must be signed in to change notification settings - Fork 0
routes.ini
This config file is required in order to route every request to a certain Controller, Action and View. It's possible to freely choose a save path for this file but keep in mind, to also adapt the path in the line where it says $famework = new Famework(new Famework_Config('config.ini'), new Famework_Config('routes.ini'));
(in /index.php).
- Default section
- famework_route
- famework_controller
- famework_action
- General stuff
- {root}
- Params in URL
Default routes.ini content:
[default]
famework_route = {root}/:controller/:action
famework_controller = :controller
famework_action = :action
required
The path mask for the URL which triggers this Controller.
required
The name of the Controller which should get called.
required
The name of the Action which should get called.
{root}
means famework.public_root; e.g.:
-
Example:
config.ini... [famework] public_root = /home/project ...
routes.ini
... [anything] famework_route = {root}/test famework_controller = IndexController famework_controller = testAction ...
Calling http://www.example.com/home/project/test, will execute
IndexController::testAction()
. -
Example:
config.ini as above and
routes.ini... [anything] famework_route = {root}/test/:action famework_controller = IndexController famework_controller = :action ...
Calling http://www.example.com/home/project/test/home, will execute
IndexController::homeAction()
. -
Example:
config.ini as above and
routes.ini... [default] famework_route = {root}/:controller/:action famework_controller = :controller famework_action = :action ...
Calling http://www.example.com/home/project/login/login.do, will execute
LoginController::loginDoAction()
.
Important: The longer your famework_route, the higher has the whole section to be set in the routes.ini
e.g.: famework_route = {root}/:controller/:action
comes before famework_route = {root}
For example, this is useful if you want to extract the language from the URL:
[default]
famework_route = {root}/:lang/:controller/:action
famework_controller = :controller
famework_action = :action
and in your index.php after initializing a new object of Famework
(called $famework
here):
$lang = $famwork->getRequestParam('lang');
if ($lang === NULL) {
$lang = 'de';
}
define('APPLICATION_LANG', $lang);
Calling http://www.example.com/en/index/index will execute IndexController::indexAction()
and will set APPLICATION_LANG
to "en"
.
- Home
- Getting Started
- Server Setup
- Configuration Files
- Application Structure
- Classes