From 6fbd868efdfb68d45fb6c0d35557ba346b21f086 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 14 Jul 2011 10:03:27 -0700 Subject: [PATCH] Edited readme.md via GitHub --- readme.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8698c3f9..a9bdef26 100644 --- a/readme.md +++ b/readme.md @@ -121,4 +121,43 @@ ### Cleaner URLs After setting up HTTP rewriting, you should set the **index** configuration option in **application/config/application.php** to an empty string. -> **Note:** Each web server has a different method of doing HTTP rewrites, and may require a slightly different .htaccess file. \ No newline at end of file +> **Note:** Each web server has a different method of doing HTTP rewrites, and may require a slightly different .htaccess file. + +[Back To Top](#top) + + +## Defining Routes + +- [The Basics](#routes-basics) +- [Route Wildcards & Parameters](#routes-parameters) +- [Route Filters](#route-filters) +- [Named Routes](#routes-named) +- [Organizing Routes](#routes-folder) + + +### The Basics + +Unlike other PHP frameworks, Laravel places routes and their corresponding functions in one file: **application/routes.php**. This file contains the "definition", or public API, of your application. To add functionality to your application, you add to the array located in this file. + +All you need to do is tell Laravel the request methods and URIs it should respond to. You define the behavior of the route using an anonymous method: + + 'GET /home' => function() + { + // Handles GET requests to http://example.com/index.php/home + }, + + 'PUT /user/update' => function() + { + // Handles PUT requests to http://example.com/index.php/user/update + } + +You can easily define a route to handle requests to more than one URI. Just use commas: + + 'POST /, POST /home' => function() + { + // Handles POST requests to http://example.com and http://example.com/index.php/home + } + +> **Note:** The routes.php file replaces the "controllers" found in most frameworks. Have a fat model and keep this file light and clean. Thank us later. + +[Back To Top](#top) \ No newline at end of file