Unlike cakePHP or Codeigniter, Installing Laravel is more complicated specially to those new to it. There are several things to configure especially if you are in a Windows platform.
- You need internet to conveniently install Laravel. The faster the better.
- You need Composer to install Laravel. Download and install the Windows installer based setup.
- You need to know your computer’s user name. In my case I’m in windows 10 [C:Users[USER_NAME]AppDataRoamingComposervendorbin]
- You need a server, in my case I’m using XAMPP with Apache server. (You may use other php server you want as long as you know where to go).
- You can find the official Laravel tutorial at Laravel 5.0 Installation page.
In the Laravel installation page, you have an option to use its own virtual host homestead. But if you are more comfortable using your prefer server then you may go for it.
So let’s get started installing Laravel.
First Step: Install Composer
Download and install Composer (Windows Installer).
You should know the directory of your php.exe from your server, as the composer will look for it. for XAMPP users you can go to DRIVE_NAME://xampp/php/php.exe
You can test if composer is successfully installed by going to your command prompt then type ‘composer’. If the command prompt displays list of composer’s commands, then your good to go.
Note: you can’t install it without internet.
Second Step: Install Laravel via Composer
Fourth Step: Adding Laravel to your computer’s Environment Variable
Once Laravel is successfully installed, Open command prompt and change directory to where your xampp/htdocs is. Start a new project by typing. ‘laravel new project_name‘.
Now, you may encounter an error like “laravel is not recognized as an internal or external command, operable program or batch file.”
This happens because your system doesn’t know laravel just yet. You may have installed it, but still it doesn’t marry to your system. To solve this problem.
- You need to identify the current user of your computer. You can find it in control panel user account name.
- Once you identified it, paste this code to the address bar of the explorer [C:\Users\[USER_NAME]\AppData\Roaming\Composer\vendor\bin]. Change the USER_NAME to your user name. Once directory is confirmed, you can now proceed to the next step.
- Right click on My Computer->Properties->Advanced System Settings->Environment Variable. In the system variables’ variable, find path. Click edit. Add a semi-colon (no space). Paste the directory C:\Users\[USER_NAME]\AppData\Roaming\Composer\vendor\bin with the right user name. Click ok.
- Restart your command prompt and change directory to where your xampp/htdocs is.
Fifth Step: Create new Laravel 5 project
Open command prompt and change directory to where your xampp/htdocs is. Start a new project by typing. ‘laravel new project_name‘.
Make sure to start your server.