What is the concept of controller in Laravel

0 votes
what the the useful work of controller in MVC??
Mar 18, 2020 in Laravel by kartik
• 37,520 points
1,714 views

1 answer to this question.

0 votes

Hii,

In the MVC framework, the letter ‘C’ stands for Controller. It acts as a directing traffic between Views and Models

In order to create controller

Open the command prompt or terminal based on the operating system you are using and type the following command to create controller using the Artisan CLI (Command Line Interface).

php artisan make:controller <controller-name> --plain

Replace the <controller-name> with the name of your controller. This will create a plain constructor as we are passing the argument — plain. If you don’t want to create a plain constructor, you can simply ignore the argument. The created constructor can be seen at app/Http/Controllers.

You will see that some basic coding has already been done for you and you can add your custom coding. The created controller can be called from routes.php by the following syntax.

Syntax

Route::get(‘base URI’,’controller@method’);

Thank you!!

answered Mar 18, 2020 by Niroj
• 82,800 points