Laravel controllers are an essential feature in a Laravel framework.Controllers can group related request handling logic into a single class. Controllers are stored in the app/Http/Controllers directory.
Creating a Controller in laravel
You open the command prompt or terminal based on the operating system you are using the below command to create controller using the Artisan CLI .
php artisan make:controller
Replace your controller's name. This will create an obvious builder as we convey the argument - it is clear. If you don’t want to create an obvious builder you can just ignore the controversy. The custom builder can be seen in the app/Http/Controllers.
Syntax :
Route::get(‘base URI’,’controller@method’);
Example :
Step 1 : Enter the following command to you can create UserController.
php artisan make:controller UserController
Step 2 : After successful execution, you will receive the following output.
Step 3 : You can see the created controller at app/Http/Controller/UserController.php with some basic coding already written for you and you can add your own coding based on your need.
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; class UserController extends Controller { } ?>