Birmingham mumbai


$ php artisan app:name Furbook


Download 1.3 Mb.
Pdf ko'rish
bet55/68
Sana05.01.2022
Hajmi1.3 Mb.
#227543
1   ...   51   52   53   54   55   56   57   58   ...   68
Bog'liq
Laravel 5 Essentials

$ 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


Download 1.3 Mb.

Do'stlaringiz bilan baham:
1   ...   51   52   53   54   55   56   57   58   ...   68




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling