How to Install Laravel on Windows

In a previous post I mentioned how Symfony offers a collection of decoupled components, which can be a benefit when you do not wish to commit to a full-fledged framework. Recently, however, I needed to quickly create a PHP application for a work project and decided to use Laravel – the most popular PHP framework – as I knew I could get it up and running quickly.

Here are my very brief notes on how to do so in a Windows server environment:

First, I installed a Wamp server:

http://www.wampserver.com/en/

Wamp is a quick installer that generates PHP, MySQL, and an Apache web server.

Second, you will need to install Composer if you do not already have it running on your machine.:

https://getcomposer.org/download/

Composer is a dependency management tool that will allow you to install components in PHP.

Note that during the installation it will allow you to choose the command line PHP you want to use. Mine correctly defaulted to the PHP installation within my Wamp directory. If it does not do so or if you have installed Wamp on another drive, you will want to navigate to php.exe that is located within your Wamp folder.

Finally, create the Laravel project for your application.

The easiest way to do so is to open a command prompt, navigate to the www folder within your wamp directory, and enter the following:

composer create-project –prefer-dist laravel/laravel myproject

Change the ‘my project’ name to whatever you wish to call your application. (Note: the dash before ‘prefer’ in the above command line should be a double dash; WordPress is converting it to an em-dash.)

After that, from the command line you can navigate to your new project directory and verify the installation with the following command:

php artisan serve

You should get a message that says something like:

Laravel server started on http://localhost:8000

Visit that url in your browser and you should see the default Laravel screen, meaning your installation is successful.

For a video walkthrough, see Rakshith Vasudev’s excellent Laravel series.

Advertisements