Due to the Kohana framework in the domestic user less, and the new version with Kohana2. X the difference is too large, plus kohana3 data for more than English. Let a lot of kohana interested in, want to learn students can only hope K sigh. As the company recently turned to KOHANA3 development (kohana3.1.0 Stable Edition), so I took the opportunity to take a serious look at the official information. Benefit A lot, Borrow personal small station, share to everybody. Today, let's say Kohana routing settings.
Again, I use the ko3.1.0 and Ko3 have the difference.
In fact, Kohana3 's routing settings are simple. Open the bootstrap.php under the application file and find the Route::set, and see the following default route:
Copy Code code as follows:
Route::set (' Default ', ' ((//)) ')
->defaults Array (
' Controller ' => ' welcome ',
' Action ' => ' index ',
));
This is the default route, you can see that it is the composition of this. Name, controller, action, parameters. In particular, each route must specify the default control and action, typically index.
How to create a custom route, in fact, is the same as the default, but just add what you want to add. For example, there is a product list page that needs to get the ID of the product type and the current page number.
Routing can be set like this
Copy Code code as follows:
Route::set (' Product ', ' product/((/) (/)) ')
->defaults Array (
' Controller ' => ' product ',
' Action ' => ' index ',
' ID ' =>0,
Some examples of ' page ' =>0//here are null, but I used an error.
));
Here, the first product is the name, followed by the focus of the place, product is the controller,/action is the action, must be so written. The back (/<>) inside is the parameter. Get here in the page parameter is this, $id = $this-> Request->param (' id '), the ID inside this, must be the same as the ID name inside the route.
Students need to refer to this example to change, should be able to. Outstanding, I highly recommend that you look at the 2 station things
1.http://kohanaframework.org/3.1/guide (official online documentation)
2.http://kerkness.ca/wiki/doku.php (unofficial wiki, example is better than official, but version 3.0)
Can be compared to see, I believe we can play Kohana, refueling!!