Adding routes with parameters in Laravel project
We can capture segments of the request URI within out route.php.
Example
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ // will return 'Hello project root' on browser request /laravel/public Route::get('/', function() { return "Hello project root"; }); Route::get('person/{name?}', function($name = null) { return "Person : " . $name; });
Output
URL : laravel/public/person/34
Output : Person : 34