Phpbeginner5 min read

Complete PHP 8.4 setup on Windows

Install PHP 8.4, configure php.ini, enable required extensions, and add PHP to PATH.

1. Download PHP

From the official PHP Windows downloads, download:

PHP 8.4 → VS17 x64 Thread Safe

Extract it to:

D:\php84

You should have:

D:\php84\php.exe
D:\php84\ext\
D:\php84\php.ini-development
D:\php84\php.ini-production

2. Install Visual C++ Redistributable

PHP's Windows builds require the Microsoft Visual C++ Redistributable.

Install the x64 Visual C++ Redistributable for Visual Studio 2015–2022 from Microsoft.


3. Create php.ini

Copy:

Copy-Item D:\php84\php.ini-development D:\php84\php.ini

Now you have:

D:\php84\php.ini

4. Configure PHP extensions

Open:

notepad D:\php84\php.ini

Find:

;extension_dir = "./"

Make sure you have:

extension_dir = "ext"

Then enable the extensions Laravel/Composer commonly needs.

Find these:

;extension=curl
;extension=fileinfo
;extension=mbstring
;extension=openssl
;extension=pdo_mysql
;extension=mysqli

Change them to:

extension=curl
extension=fileinfo
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=mysqli

Also useful for Laravel:

extension=intl
extension=zip

So enable:

extension=intl
extension=zip

Your important extensions are therefore:

extension=curl
extension=fileinfo
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=mysqli
extension=intl
extension=zip

5. Add PHP to Windows PATH

Open:

Start → Edit the system environment variables → Environment Variables

Find Path.

Add:

D:\php84

If you already have other PHP versions:

D:\php83
C:\php85
D:\php84

put:

D:\php84

above the other PHP directories.

For example:

D:\php84
D:\php83
C:\php85
C:\Users\ADMK-Solutions\.config\herd-lite\bin

Windows uses the first matching php.exe it finds.


6. Restart your terminal

This is important.

Close PowerShell/CMD completely.

Open a new PowerShell.

Run:

where.exe php

You want:

D:\php84\php.exe

to be the first result.

Then:

php -v

You should see:

PHP 8.4.x

7. Check which php.ini PHP is using

Run:

php --ini

You want:

Loaded Configuration File: D:\php84\php.ini

If it says (none), your php.ini isn't configured correctly.


8. Check PHP extensions

Run:

php -m

Or check the important ones together:

php -m | Select-String "curl|fileinfo|mbstring|openssl|pdo_mysql|mysqli|intl|zip"

You should see something similar to:

curl
fileinfo
intl
mbstring
mysqli
openssl
pdo_mysql
zip

This step is very important.

For example, your earlier Composer error:

requires ext-fileinfo

happened because:

;extension=fileinfo

was still commented out.

And your migration error:

could not find driver

happened because:

;extension=pdo_mysql

wasn't enabled.


9. Check Composer

If Composer is already installed:

composer --version

Then:

composer diagnose

Composer should now be using your PHP 8.4 installation.

You can check:

composer about

10. Go to your Laravel project

cd D:\afzaal\restaurant-sass

Check PHP:

php -v

Then install dependencies:

composer install

Don't run composer update unless you specifically need to update dependencies.

composer install uses your existing composer.lock.


11. Create .env

If .env doesn't exist:

Copy-Item .env.example .env

Then:

php artisan key:generate

You should get:

Application key set successfully.

12. Configure MySQL

Since you're not using Docker, your MySQL must be running directly on Windows.

For example, if using XAMPP:

XAMPP
 ├── Apache
 └── MySQL 

Start MySQL.

Then your .env might look like:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=restaurant_sass
DB_USERNAME=root
DB_PASSWORD=

If your MySQL root user has a password:

DB_PASSWORD=your_password

13. Create the database

You need a database called:

restaurant_sass

You can create it through:

  • phpMyAdmin

  • MySQL command line

  • MySQL Workbench

For example, SQL:

CREATE DATABASE restaurant_sass;

14. Test MySQL connection

Check whether MySQL is listening on port 3306:

Test-NetConnection 127.0.0.1 -Port 3306

You want:

TcpTestSucceeded : True

If you get:

False

your MySQL server isn't running or isn't using port 3306.


15. Clear Laravel configuration

After changing .env:

php artisan config:clear

You can also run:

php artisan cache:clear

16. Run migrations

Now:

php artisan migrate

If everything is configured correctly:

INFO  Preparing database.

INFO  Running migrations.

17. Install Node dependencies

Your Laravel React/Inertia application also needs Node.

Check:

node -v
npm -v

Then from your project:

npm install

18. Start the application

For development, you can use your project's Composer script:

composer run dev

Or run Laravel and Vite separately:

Terminal 1:

php artisan serve

Terminal 2:

npm run dev

Laravel will normally be available at:

http://127.0.0.1:8000

Your complete flow

When installing a new PHP version, remember this order:

1. Download PHP
       ↓
2. Extract PHP
       ↓
3. Install Visual C++ Redistributable
       ↓
4. Create php.ini
       ↓
5. Set extension_dir
       ↓
6. Enable PHP extensions
       ↓
7. Add PHP to Windows PATH
       ↓
8. Restart terminal
       ↓
9. php -v
       ↓
10. php --ini
       ↓
11. php -m
       ↓
12. composer --version
       ↓
13. cd Laravel-project
       ↓
14. composer install
       ↓
15. Copy .env.example → .env
       ↓
16. php artisan key:generate
       ↓
17. Start MySQL
       ↓
18. Configure .env
       ↓
19. php artisan config:clear
       ↓
20. php artisan migrate
       ↓
21. npm install
       ↓
22. composer run dev

For your particular machine

You currently have multiple PHP installations, so your main thing to watch is:

where.exe php

The first result determines which PHP your terminal uses.

For this Laravel project, make sure it is:

D:\php84\php.exe

Then make sure:

php --ini

shows:

D:\php84\php.ini

and:

php -m | Select-String "openssl|fileinfo|pdo_mysql"

shows all three.

That three-part check will prevent the exact Composer and MySQL errors you just encountered.

Complete PHP 8.4 setup on Windows | Java Guide | Afzaal Suleman