A Controller is that which controls the behavior of a request. It handles the requests coming from the Routes. In Laravel, a controller is in the ‘app/Http/Controllers’ directory. All the controllers, that are to be created, should be in this directory.
We can create a controller using ‘make:controller’ Artisan command.
Syntax
php artisan make:controller UserController
You can specify any name in place of ‘User’, but according to the naming convention of Laravel, you have to specify the word ‘Controller’ at the end for any name you specify.
Example
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class GfGController extends Controller
{
public function index() {
return view('gfg');
}
}