First time ever installing PHP and Laravel on Windows
Tags: php, laravel, beginners
Published: 2019-06-04 01:06:10

Today I decided to take a crack at setting up a Laravel environment on my personal machine. I did a tiny bit of Laravel coding at my previous job, but I wanted to build something from scratch that I could use for a portfolio project. I found a good tutorial on YouTube, but two hours after starting I was still only 8 minutes into the video. I missed a critical step, and I kept running into issues. In the end everything was super easy to fix, but I'm documenting the setup process for future reference, and hopefully this will save someone else some grief as well.

As a disclaimer, I'm on Windows and using the latest software releases as of Jun 2019. Mileage may vary.

First thing to do is [download](https://www.php.net/) and setup PHP. I downloaded version 7.1.30.

![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/php_download.png)

Next create a folder where you want PHP to live. I created mine at the root of C the drive. 

![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/php_folder.png)

After the PHP file has downloaded, extract the contents of the zip file to your new folder. And add the folder location to your `PATH`.

![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/env.PNG)

Next copy/rename the `php.ini-development` file to be called `php.ini`. It's very important that this file exists.

![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/php_directory.png)

In the newly created file configure the extensions by searching for and un-commenting these lines of code:

```
extension_dir = "ext"
extension=openssl
extension=mbstring
extension=fileinfo

```
![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/extension_dir.png)

![windows download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/extensions.png)

The first two lines of code above solve the following error when trying to install Laravel via Composer:

```
[Composer\Exception\NoSslException]                 
```

And by modifying the `ini` file to include the necessary extensions this *should* prevent composer from trying to modify the file during install.

Next install [Composer](https://getcomposer.org/download/). For me downloading the `exe` and installing with accepting the defaults was sufficient. 

![composer download](https://raw.githubusercontent.com/davdaarn/assets/master/assets/blog_post1/composer_installer.png)

After Composer is installed run:

```
composer global require laravel/installer
```

Then you should be able to run:

```
laravel new myFirstProject
```

And hopefully you will be free from errors. If you do encounter any errors it's likely an issue with the `ini` file and missing extensions.

I know that this installation process is very trivial and hardly in need of a guide ( and there are probably better ways to get setup). But being new to the world of PHP the setup process was a bit foreign to me and I managed to get hung up for bit. Hope this helps someone.