Now that we have filled in the previous information and downloaded the file for our machine, let's begin setting up our application so as to delve deeper into the directory structure of a Laravel application.
Execute the following steps:
- Open bash/Terminal/cmd.
- Go to Users/yourname on Mac and Linux, or C:/ on Windows.
- Open your Terminal inside the folder and type the following command:
composer create-project --prefer-dist laravel/laravel chapter-01
At the end of your Terminal window, you will see the following result:
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
php artisan key:generate
- In the Terminal window, type:
cd chapter-01 && ls
The results will be as follows:
Terminal window output
Congratulations! You have your first Laravel application, built with the Composer package manager.
Now, it's time to join our application with the file downloaded from PHPDocker (our PHP/MySQL Docker screenshot). To do so, follow the next steps.
- Grab the downloaded archive, hands-on-full-stack-web-development-with-angular-6-and-laravel-5.zip, and unzip it.
- Copy all of the folder content (a phpdocker folder and a file, docker-compose.yml).
- Open the chapter-01 folder and paste the content.
Now, inside the chapter-01 folder, we will see the following files:
chapter-01 folder structure
Let's check to make sure that everything will go well with our configuration.
- Open your Terminal window and type the following command:
docker-compose up -d
- Note that this command may take more time to create and build all of the containers. The results will be as follows:
Docker containers up and running
The preceding screenshot indicates that we have started all containers successfully: memcached, webserver (Nginx), mysql, and php-fpm.
Open your browser and type http://localhost:8081; you should see the welcome page for Laravel.
At this point, it is time to open our sample project in a text editor and check all of the Laravel folders and files. You can choose the editor that you are used to, or, if you prefer, you can use the editor that we will describe in the next section.