Install Laravel on Windows

Install Laravel on Windows

This is going to assume we are starting from scratch using a fresh install of WAMP 2.4 on Windows. In doing this myself, I ran into a few gotchas so this post will document those hiccups and get you running with Laravel right away. Update: We now also have a guide to Install Laravel Homestead on Windows if you prefer a Virtual Machine environment! So read on if you’d like to install right on the local machine with WAMP, or follow the link above if you’re ready for Laravel Homestead.


Install Wamp

Start by getting a nice fresh copy of wamp over at http://www.wampserver.com/en/

Install Composer

Now we can install Composer. This is great, let’s go ahead and do that by visiting http://getcomposer.org/ and download the windows installer now. Once the installer is downloaded, go ahead and doubleclick the file to begin installing composer on your Windows machine.

Install Laravel

Now you are excited, you are ready to rock with Laravel. We got Wamp. Check. We got Composer. Check. We got Game. Check.

Let’s run the command: composer create-project laravel/laravel blog --prefer-dist

in the www root directory of WAMP. I can’t wait to see this in action! Whoops, I don’t think we were supposed to see this:

Result: [RuntimeException] You must enable the openssl extension to download files via https

Ok, fair enough. Let’s go ahead and enable the PHP extension in WAMP. It’s so easy after all, all we have to do is click the WAMP Icon in the task tray, choose PHP->PHP Extensions->php_openssl! Now we can restart all services and DO THIS.

Run the command: composer create-project laravel/laravel blog --prefer-dist

Result: [RuntimeException] You must enable the openssl extension to download files via https

WHAT THE …?! Still getting errors and no install. But it said to enable open SSL, and my extension has a nice checkmark next to it in WAMP, WHAT IS THE DAMN PROBLEM?!

Turns out, if you enable open SSL through the wamp UI, it doesn’t actually turn it on. After perusing stack overflow, I find that you also have to navigate to your C:wampbinphpphp5.4.16 folder and uncomment the extension=php_openssl.dll in the php.ini file.

Ok let’s remove the ; to uncomment openssl, restart all services, and DO THIS. No this time, I really mean DO THIS!!

Run the command: composer create-project laravel/laravel blog --prefer-dist

Bingo Bango! – ok, no errors, it’s thinking, oh wow – we’re really downloading some awesome stuff now!

C:wampwww>composer create-project laravel/laravel blog --prefer-dist
Installing laravel/laravel (v4.1.0)
  - Installing laravel/laravel (v4.1.0)
    Downloading: 100%

Created project in blog
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing filp/whoops (1.0.10)
    Downloading: 100%

  - Installing psr/log (dev-master 65f363a)
    Downloading: 100%

  - Installing symfony/routing (2.4.x-dev e4ef317)
    Downloading: 100%

  - Installing symfony/translation (2.4.x-dev d08c270)
    Downloading: 100%

  - Installing symfony/process (2.4.x-dev 4f196b9)
    Downloading: 100%

  - Installing symfony/finder (2.4.x-dev b6735d1)
    Downloading: 100%

  - Installing symfony/console (2.4.x-dev 86e13d5)
    Downloading: 100%

  - Installing symfony/filesystem (dev-master e81f1b3)
    Downloading: 100%

  - Installing symfony/debug (2.4.x-dev 7bd0447)
    Downloading: 100%

  - Installing symfony/http-foundation (2.4.x-dev 25b49c4)
    Downloading: 100%

  - Installing symfony/event-dispatcher (dev-master a37a943)
    Downloading: 100%

  - Installing symfony/http-kernel (2.4.x-dev eb1ed60)
    Downloading: 100%

  - Installing symfony/dom-crawler (2.4.x-dev fa7d0ca)
    Downloading: 100%

  - Installing symfony/css-selector (2.4.x-dev 251273e)
    Downloading: 100%

  - Installing symfony/browser-kit (2.4.x-dev c6b3cd5)
    Downloading: 100%

  - Installing swiftmailer/swiftmailer (v5.0.3)
    Downloading: 100%

  - Installing stack/builder (dev-master 49ab904)
    Downloading: 100%

  - Installing predis/predis (0.8.x-dev d2debfd)
    Downloading: 100%

  - Installing phpseclib/phpseclib (dev-master 268ec2e)
    Downloading: 100%

  - Installing patchwork/utf8 (v1.1.17)
    Downloading: 100%

  - Installing nesbot/carbon (1.8.0)
    Downloading: 100%

  - Installing monolog/monolog (dev-master a1e98f4)
    Downloading: 100%

  - Installing nikic/php-parser (dev-master 0353c92)
    Downloading: 100%

  - Installing jeremeamia/superclosure (1.0.1)
    Downloading: 100%

  - Installing ircmaxell/password-compat (1.0.x-dev 1fc1521)
    Downloading: 100%

  - Installing d11wtq/boris (v1.0.6)
    Downloading: 100%

  - Installing classpreloader/classpreloader (1.0.1)
    Downloading: 100%

  - Installing laravel/framework (4.1.x-dev a49d68a)
    Downloading: 100%

symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/translation suggests installing symfony/config ()
symfony/translation suggests installing symfony/yaml ()
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/http-kernel suggests installing symfony/class-loader ()
symfony/http-kernel suggests installing symfony/config ()
symfony/http-kernel suggests installing symfony/dependency-injection ()
predis/predis suggests installing ext-phpiredis (Allows faster serialization and deserialization of
the Redis protocol)
predis/predis suggests installing ext-curl (Allows access to Webdis when paired with phpiredis)
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension
in order to speed up arbitrary precision integer arithmetic operations.)
phpseclib/phpseclib suggests installing pear-pear/PHP_Compat (Install PHP_Compat to get phpseclib wo
rking on PHP >= 4.3.3.)
patchwork/utf8 suggests installing ext-intl (Use Intl for best performance)
monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
d11wtq/boris suggests installing ext-readline (*)
d11wtq/boris suggests installing ext-pcntl (*)
d11wtq/boris suggests installing ext-posix (*)
laravel/framework suggests installing doctrine/dbal (Allow renaming columns and dropping SQLite columns.)
Writing lock file
Generating autoload files
Generating optimized class loader
Application key [H3tKsDs7StT9ZIuDXaUfcXY33XYvPJQJ] set successfully.

C:wampwww>

Blog project built. Awesome. Ok, small setbacks aside – I’m ready to really rock and roll – let’s create our first route! Per the docs at Laravel, lets add this code to our routes.php file


Route::get('users', function()
{
    return 'Users!';
});

Now, if you hit the /users route in your web browser, you should see Users! displayed as the response. Great! You’ve just created your first route. Ok, let me try it

Hit it: http://localhost/blog/public/users

Not Found

The requested URL /users was not found on this server.

WHAT THE…?! oh yeah, we also need to enable mod_rewrite in apache. Ok, go uncomment the line LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf. Restart all services, Try again: http://localhost/blog/public/users

Users!

Awesome – I’m outputting Users!

Well, there you have it – in case you find yourself not actually going as fast as the docs make it seem you will, this guide gave you the step by step in getting Composer and Laravel installed in a Windows WAMP 2.4 environment, and we went from zero to hero, or rather zero to our first route in no time flat. Now that you are up and running go check out Crud In Laravel 4!