DEV Community

Cover image for Easiest Laravel Installation with PHP 8.0 for Windows 10
Justin Williams
Justin Williams

Posted on • Updated on

Easiest Laravel Installation with PHP 8.0 for Windows 10

Quick Introduction

Almost every programming Crash Course I have ever viewed starts with basic setup and installation...except for most Laravel courses which assume you either have PHP, Composer, or Laravel already installed. With a JavaScript-based framework/library that is not usually a problem, but if you are new to the PHP space this can be a bit of a headache.

I hope this post will take the struggle out some of the Laravel setup and __by the end of this tutorial you should be able to:

  • use PHP
  • run composer
  • create a new Laravel project without any errors!

Note:

-If you have already tried setting up Laravel and are having issues with PHP or Composer, I would recommend deleting your current installation files and their related PATH's and start over at Step 1.\
-If you are currently having problems with php.ini and fileinfo, like many of us starting with PHP 8, hopefully Step 5 will help.


Step 1 - Download and Extract the PHP zip file

  1. Download PHP zip file from https://windows.php.net/download/ php download
  2. Create a new folder in the C drive called "php8". This will make your PHP files easily accessible. easy php
  3. Extract Downloaded PHP files to your new php8 folder extract php

Step 2 - Download and Install Composer

  1. Download Composer-Setup.exe from getcomposer.org/download download composer
  2. Run the file and make sure that C:\php8\php.exe is your command line PHP and that a php.ini file is created. You can skip the Proxy Server Prompt. image

Step 3 - Check to see if PHP and Composer are working

  1. Open your Command Prompt and type php -v . After you press Enter, you will see your PHP version number.
  2. In the Command Prompt check for your composer in the same way with composer -v You will see the version number in addition to a list of commands composer can run. testing

Step 4 - Install Laravel Globally with Composer

In the Command Prompt enter:

composer global require laravel/installer
Enter fullscreen mode Exit fullscreen mode

and the Laravel will be installed on your system.


Step 5 - Update the php.ini file

Problem

Laravel is now installed globally but when you try to create new file by typing:

laravel new example-app
Enter fullscreen mode Exit fullscreen mode

the project will only be partially created and will throw the following error:

Problem 1
- laravel/framework[v8.12.0, ..., 8.x-dev] require league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.0, ..., 1.x-dev].
- league/flysystem[1.1.0, ..., 1.x-dev] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- Root composer.json requires laravel/framework ^8.12 -> satisfiable by laravel/framework[v8.12.0, ..., 8.x-dev].
Enter fullscreen mode Exit fullscreen mode

Solution

The problem is that your php.ini file is missing the fileinfo and init extensions. The extensions are written into your php.ini file but need to be uncommented manually. Here is how to do it:

  1. Open the php.ini file in your php8 folder. If you have not sorted your files is the file right below php.exe but right above php.ini-development. You can also search for it using the file explorer. Then open the file in either Notepad or VScode. php.ini
  2. Once the file is open, search for the text "fileinfo" with no spaces and you will come to a long list of extensions. Remove the ; from in front of ;extension=fileinfo and ;extension=intl

remove semicolons

  1. Save the file and you are set! Time to create a new Laravel file and begin coding!
laravel new example-app
Enter fullscreen mode Exit fullscreen mode

Top comments (0)