Appearance
Configuring Routes
Routing
Routing refers to how an application’s endpoints (URIs) respond to client requests. For an introduction to routing, see Basic routing.
The most basic Laravel routes accept a URI and a closure, providing a very simple and expressive method of defining routes and behavior without complicated routing configuration files. The following code is an example of a very basic route.
use Illuminate\Support\Facades\Route;
// respond with "hello world" when a GET request is made to the homepage
Route::get('/', function () {
return 'Hello World';
});
Laravel Routes
All laravel routes are defined in route file, which are located in route directory. The routes file are loaded by App\Providers\RouteServiceProvider.
The following example create routes with prefix and namespace, loads a middleware function with designated controllers, defines some routes, and mounts the route to specific path.
Eg: Create a route file named web.php in the routes directory, with the following content:
Route::group(['namespace' => 'System', 'prefix' => PREFIX, 'middleware' => ['language', 'pinewheel-log']], function () {
Route::get('/admin', 'admin\AdminController@index');
Route::post('/admin/create', 'admin\AdminController@store');
Route::put('/admin/{id}/edit', 'admin\AdminController@update');
Route::delete('admin/{id}', 'admin\AdminController@delete');
});