-
Notifications
You must be signed in to change notification settings - Fork 1
Routes
As of release v1.0, it is possible to use either XML or JSON to write routes, JSON being the new default. On older installations of APIne, when migrating to v1.0 the content of the older routes.xml
file will be automatically exported to a JSON file and a new entry in the configuration file will be written. Routes are used by the web app but not by the API.
As of release v1.1, the use of XML route configuration is deprecated.
It is possible to use either XML or JSON in APIne v1.0. By default, the framework will attempt to use JSON and will automatically export the content XML file if the JSON file is not found. To change that behavior, you can add or modify the route_format
in the runtime
section of the configuration and set it to either json
or xml
.
Routes are written in the routes.json
file located at the rout of the project's directory.
-
args
:true
orfalse
Mandatory Does the router has to look for arguments in the query string; -
argsnum
:integer
Optional How many arguments are there in the query string; -
controller
: Mandatory Destination controller name; -
action
: Mandatory Destination action name;
"/user/([0-9]+)" : {
"GET" : {
"args": true,
"controller": "user",
"action": "profile"
},
"POST" : {
"args": true,
"controller": "user",
"action": "save"
}
}
Routes are written in the routes.xml
file located at the root of the project's directory.
A route is represented by a <route>
tag and has three childs nodes <request>
, <controller>
and <action>
.
-
args="true|false"
: Mandatory Does the router has to look for arguments in the query string; -
argsnum=number
: Optional How many arguments are there in the query string; -
method="GET|POST|DELETE|PUT"
: Mandatory Which request method does this route accept.
-
<request>
: Mandatory A regular expression whose the router matches with the query string -
<controller>
: Mandatory Destination controller name -
<action>
: Mandatory Destination action name
<route args="true" argsnum=1 method="GET">
<request>/user/([0-9]+)</request>
<controller>user</controller>
<action>profile</action>
</route>
This route refers to a request through the GET method with one argument in the query string and redirects to the profile action in the user controller.
- Introduction
- Getting Started
- Requirements & Installation
- Application Configuration
- Database Connection
- How to use Controllers
- How to use Views
- How to Manage Session
- How to use the api (Coming Soon)
- Utilities
- Entity Manager
- File Manager
- Access and Save File (Coming Soon)
- Image Methods (Coming Soon)
- XML Manager
- XML Class (Coming Soon)
- Parser (Coming Soon)
- Writer (Coming Soon)
- Advanced Topics
- Extended Users
- Routes
- Templating (Coming Soon)
- Translations and Locales