Lesson 3: First Laravel Application

In this lesson, you will be creating your first Laravel application. Once you are done with the steps in Lesson 2: Setup Laravel Development Environment, its very easy to do this.

1. Creating “myFirstApp”

Suppose the name of your first application is myFirstApp.

1. Open your Terminal and run the following command:

It will take a few minutes to complete and you will need a working internet connection. In the end, the output will be like this:

Thats it! Really. New Laravel application has been created and is ready to run.

2. The code of your new application will be in the folder myFirstApp. Move to this folder in your Terminal and run the following command:

Your application is now running. To access it, go to:

http://localhost:8000/

You should see a screen like this:

Laravel Application Running

Congratulations! You have successfully run a Laravel Application.

2. Running the application through Apache

Notice that we used php artisan serve  command to run the application. This command internally uses php’s built-in web server to run the application.

If you want to run the application through Apache (like you would be doing for your previous php applications till now), you just need to ensure that your application folder myFirstApp is inside Apache’s document root (htdocs or www in most cases). Then you need to visit following link:

http://localhost/myFirstApp/public/

You should see the same screen as above.

However, throughout the tutorials, we will be using  internal server method of running the application.

Note: Notice the public at the end of the URL. In Laravel, all your publicly accessible assets, like, Images, JavaScripts, CSS, and etc. are placed in public folder. So, all your routes will also be accessed through public folder. This is a security measure to prevent access to your code files. 

 

Lesson 4: Laravel Application Structure

 

 

Share this article: