$ php artisan app:name Furbook
This will update our application's namespace to be
Furbook
instead.
Writing the first routes
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
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
routes work by opening your web browser and visiting
http://dev.furbook.com/
cats/123
.
Chapter 3
Do'stlaringiz bilan baham: |