Create Your First Controller in Laravel

In this lesson we will see how to create your first controller in Laravel. If you do not know how to install Laravel in your computer you can see the this tutorial

This is the directory structure of the Laravel project

So you can create your controller App > Http > Controllers

You can run following command inside the terminal

This will create the following code

Now I will create the show() inside the UserController

Now you can define the route for this controller action in routes>web.php file

 

Leave a Reply

Your email address will not be published. Required fields are marked *