April 2015
Beginner
144 pages
3h 13m
English
Let's start by writing the first two routes of our application at app/Http/routes.php. This file already contains some comments as well as a couple of sample routes. Remove the existing routes (but leave the opening <?php declaration) before adding the following routes:
Route::get('/', function() {
return 'All cats';
});
Route::get('cats/{id}', function($id) {
return sprintf('Cat #%s', $id);
});The first parameter of the get method is the URI pattern. When a pattern is matched, the closure function in the second parameter is executed with any parameters that were extracted from the pattern. Note that the slash prefix in the pattern is optional; however, you should not have any trailing slashes. You can make sure that your ...
Read now
Unlock full access