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:
$ laravel new myFirstApp
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:
vagrant@homestead:~/Code$ laravel new myFirstApp
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
> php artisan optimize
Generating optimized class loader
> php artisan key:generate
Application key [LODvhhkni8OnivQe4X4OEKFDjJpvQ7Rp] set successfully.
Application ready! Build something amazing.
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:
$ php artisan serve
Your application is now running. To access it, go to:
You should see a screen like this:
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:
You should see the same screen as above.
However, throughout the tutorials, we will be using internal server method of running the application.
Lesson 4: Laravel Application Structure