To install Laravel there is a little learning curb to grasp for those who are novice and want to enter into the laravel world.
Homestead :
It is the official laravel development environment. All of the Laravel framework requirements are satisfied by this virtual machine. so it's highly recommended that you use Homestead as your local Laravel development environment.
XAMPP :
Many Developers are experienced with Xampp environment for their PHP projects. So, I am going here to details of laravel installation in Xampp environment. Basically who are new and want to start their projects with Laravel in their familiar Xampp environment this article will be helpul for them.
Followings things are prerequisite to install Laravel:
1. Internet connection. Faster is better
2. CLI (Command Line Interface). Unfortunately Windows cmd is not good. I prefer Git Bash.
3. Composer. It's a PHP dependency manager. It will load necessary PHP library and Laravel utilizes Composer to manage its
dependencies.
4. I assumed you have Xampp installed in your machine. Those who are familiar with other PHP server like: WAMP or
anything else the installation process is same as long as you know what to do.
Let's get started installing Laravel:
1. Install Composer - Download
i) Download and install the Windows installer based setup.
ii) Composer will look for your local php application path. For Xampp users it may be C://xampp/php/php.exe
iii) Select "Install Shell Menus" under "Shell Menu - optional". You will later get advantage by selecting this option.
iv) Follow the simple instructions, you should have Composer installed.
v) Windows installer will install the latest Composer version and set up your PATH automatically so that you can just call
composer from any directory in your command line.
2. Install Git Bash - Download
i) Download and install the Windows installer based setup.
ii) When it asks something, you should accept the default options.
iii) Follow the simple instructions, you should have Git Bash installed.
Open Git Bash and type composer, hit Enter
You should see something like this:
Homestead :
It is the official laravel development environment. All of the Laravel framework requirements are satisfied by this virtual machine. so it's highly recommended that you use Homestead as your local Laravel development environment.
XAMPP :
Many Developers are experienced with Xampp environment for their PHP projects. So, I am going here to details of laravel installation in Xampp environment. Basically who are new and want to start their projects with Laravel in their familiar Xampp environment this article will be helpul for them.
Followings things are prerequisite to install Laravel:
1. Internet connection. Faster is better
2. CLI (Command Line Interface). Unfortunately Windows cmd is not good. I prefer Git Bash.
3. Composer. It's a PHP dependency manager. It will load necessary PHP library and Laravel utilizes Composer to manage its
dependencies.
4. I assumed you have Xampp installed in your machine. Those who are familiar with other PHP server like: WAMP or
anything else the installation process is same as long as you know what to do.
Let's get started installing Laravel:
1. Install Composer - Download
i) Download and install the Windows installer based setup.
ii) Composer will look for your local php application path. For Xampp users it may be C://xampp/php/php.exe
iii) Select "Install Shell Menus" under "Shell Menu - optional". You will later get advantage by selecting this option.
iv) Follow the simple instructions, you should have Composer installed.
v) Windows installer will install the latest Composer version and set up your PATH automatically so that you can just call
composer from any directory in your command line.
2. Install Git Bash - Download
i) Download and install the Windows installer based setup.
ii) When it asks something, you should accept the default options.
iii) Follow the simple instructions, you should have Git Bash installed.
Open Git Bash and type composer, hit Enter
You should see something like this:
You have now Composer and Git Bash in your system.
3. Install Laravel
In 3 ways you can install Laravel in your local environment.
Method One : Using composer create-project command
a) Open gitbash and write command : $ cd c:/xampp/htdocs
b) Write command : composer create-project laravel/laravel YourLaravelProjectName
c) If fail, write again: composer create-project --prefer-dist laravel/laravel YourLaravelProjectName
d) Wait for the minutes. it can take time depending on your internet connection speed.
e) Browse http://localhost/YourLaravelProjectName/public
You should see the following:
3. Install Laravel
In 3 ways you can install Laravel in your local environment.
Method One : Using composer create-project command
a) Open gitbash and write command : $ cd c:/xampp/htdocs
b) Write command : composer create-project laravel/laravel YourLaravelProjectName
c) If fail, write again: composer create-project --prefer-dist laravel/laravel YourLaravelProjectName
d) Wait for the minutes. it can take time depending on your internet connection speed.
e) Browse http://localhost/YourLaravelProjectName/public
You should see the following:
Method Two : Using Laravel Installer
a) Open gitbash and write command : composer global require "laravel/installer"
b) If fail, write command again : composer global require "laravel/installer" --prefer-dist
This will download Laravel to your computer globally so that you can invoke it in any path you want.
The installation can take few moments depending on your internet connection
c) Open command prompt and go to xampp/hotdocs directory by : $ cd DRIVE_NAME://xampp/htdocs
d) Start a new project by writing command : laravel new YourLaravelProjectName
Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable can be
located by your system. Otherwise, you may encounter an error like “laravel is not recognized as an
internal or external command, operable program or batch file.” To solve this problem do the followings :
i) Copy the composer bin path from your system. As usual it will be like the following path where
composer installed :
C:\Users\User or Your_Computer_User_Name\AppData\Roaming\Composer\vendor\bin;
ii) Your PC -> Properties -> Advanced System Settings -> Advanced -> Environments Variables ->
Select PATH -> Edit -> In the Variable Value Box after the semicolon (if no semicolon with the
existing path give one and then after paste the above composer bin path. -> Select OK
e) Restart command prompt. change directory to where your xampp/htdocs is. Start a new project by
writing command : laravel new YourLaravelProjectName. This may take several moments
according your internet connection speed.
f) browse http://localhost/YourLaravelProjectName/public
You should see the previous laravel page.
Method Three : Using Laravel Download Zip File : Download
a) Download Laravel zip from git and extract in your xampp/htdocs/YourLaravelProjectName
b) Right click on the "YourLaravelProjectName"
c) Select "Use Composer Here" It will load cmd command line interface
d) just write "composer install" in the command line interface
or right click "Composer install" and the installation process will start automatically
e) Loading process will start and after finished browse http://localhost/YourLaravelProjectName/public
You should see the previous laravel page.
important : i) If you not select "Install Shell Menus" while installing composer, you will not get the "Use
Composer Here" or "Composer install" options while right clicking YourLaravelProjectName
ii) This method will not automatically copy .env.example to .env environment
configuration file. So you have to do this manually.
iii) You also need to generate APP_KEY manually for the .env configuration file with the
following command in the command prompt: php artisan key:generate
For more details about installation configuration.
Congratulations! You've installed Laravel! It's time to create something amazing!