Laravel 5 has been released recently and it has not disappointed its eagerly awaiting fans. Laravel 5 is packed with developer-friendly features which make coding a joyful experience. In this quick tip we will go through one of its new features called Laravel Installer. So without further ado let's jump right into it and see how we can start using Laravel Installer.
In previous Laravel versions we used Composer to set up a new project, which was a slow and time-consuming process. We can still use Composer to create a Laravel 5 project, but the Laravel 4.1 introduced Installer, which can create a project in a few seconds and is much faster than Composer.
First of all we need to download and set up Laravel Installer using Composer, which is a one-time process. Open up Terminal and issue the below command:
composer global require "laravel/installer=~1.1"
This command will download the Installer package from the Composer repository and will set up globally on your machine so that you will be able to access Installer regardless of in which directory you are in Terminal.
There is one more thing we need to do before we can start using Laravel Installer. We need to make sure that the following directory is in our PATH variable:
This will make sure that when you fire the Laravel Installer command, your system can locate the Laravel executable to action that command. To add the above directory to your PATH variable, open up Terminal and type
open .bash_profile. This will open the system bash file where you can append the code to your path by typing
export PATH=~/.composer/vendor/bin:$PATH. Then save and close the bash file.
Now you are ready to create your first Laravel 5 project using Laravel Installer. Simply issue the following command in Terminal:
laravel new project-name
This command will create a fresh copy of Laravel 5 with all dependencies installed in the directory you specify. You will notice that it creates a new project within seconds, which is a much faster and more productive way of creating a Laravel 5 project compared to Composer.
As mentioned above, you can still use Composer to create a Laravel 5 project. Simply issue the following command in Terminal:
composer create-project laravel/laravel --prefer-dist
This command will start downloading all Laravel dependencies and will set up a new project in the specified directory.
Hopefully you found this quick tip useful and will benefit from using Laravel Installer. Should you have any questions, feel free to leave a comment and I will be more than happy to help you out.