For doing jobs, tasks, work etc, Batch Processing to generate between and PDF documents, that needs to start from a web. Kohana provides a very powerful routing system. . user_id);. However, Kohana also provides a method to generate the uri from the route’s definition. This is. Kohana exception class. Generate a Response for the current Exception Exception handler, logs the exception and generates a Response object for display.

Author: Kajikree Karg
Country: United Arab Emirates
Language: English (Spanish)
Genre: Automotive
Published (Last): 17 February 2008
Pages: 17
PDF File Size: 19.29 Mb
ePub File Size: 1.72 Mb
ISBN: 192-9-23022-651-6
Downloads: 74668
Price: Free* [*Free Regsitration Required]
Uploader: Mezshura

Kohana provides a very powerful routing system.

Batch Processing generating PDF documents – Kohana Forums

In essence, routes provide an interface between the urls and your controllers and actions. With the correct routes you could make almost any url scheme correspond to almost any arrangement of controllers, and you could change one without impacting the other.

As mentioned in the Request Flow section, a request is handled by the Request class, which will look for a matching Route and load the appropriate controller to handle that request. It is important to understand that routes are matched in the order they are addedand as soon as a URL matches a route, routing is essentially “stopped” and the remaining routes are never tried. Because the default route matches almost anything, including an empty url, new routes must be place before it.

The default route is simply provided as a sample, you can remove it and replace it with your own routes. Let’s take a closer look at each of the parameters of Route:: The name of the route must be a unique string.

general:models [Kohana User Guide]

If it is not it will overwrite the older route with the same name. The name is used for creating urls by reverse routing, or checking which route was matched. The uri is a string that represents the format of urls that should be matched.


We have three keys or params: You can use any name you want for your keys, but the following keys have special meaning to the Request object, and will influence which controller and action are called:.

The Kohana route system uses perl compatible regular expressions in its matching process. You can define your own patterns for each key by passing an ggenerate array of keys and patterns as an additional third argument to Route:: In this example, we have controllers in two directories, admin and affiliate.


You can also use a less restrictive regex to match unlimited parameters, or to ignore overflow in a route. If gemerate wanted to use this for unlimited parameters, you could explode it, or you just ignore the overflow. If a key in a route is optional or not present in the routeyou can provide a default value for that key by passing an associated array of keys and default values to Route:: This can be useful to provide a default controller or action for your site, among other things.

The controller and action key must always have a value, so they either need to be required in your route not inside of parentheses or have a default value provided. Kohana automatically converts controllers to follow the standard naming convention. In the default route, all the keys are optional, and the controller and action are given a default. Here’s a simple example:. The directorycontroller and action can be accessed from the Request as public properties like so:.


Generaye other keys specified in a route can be accessed via Request:: If no arguments are given, all keys are returned as an associative array. In addition, actioncontroller and directory are not accessible via Request:: You can access the parameters by using the param method of the controller’s Request. Remember to define a default value via the second, optional parameter of Request:: Of course, nothing stops you from including them from an external file, or generahe generating them dynamically.

Along with Kohana’s powerful routing generte are included some methods for generating URLs for your routes’ uris. You can always specify your uris as a string using URL:: However, Kohana also provides a method to generate the uri from genedate route’s definition. This is extremely useful if your routing could ever change since it would relieve you from having to go back through your code and change everywhere that you specified a uri as a string.


Here is an example of dynamic generation that corresponds to the feeds route example from above:. If you wrote your code with the above uri generation method you wouldn’t have to change a single line!

When a part of the uri is enclosed in parentheses and specifies a key for which there in no value provided for uri generation and no default value specified in the route, then that part will be removed from the uri.

User Guide Kohana Routing. Powered by Kohana v3.