Moving from Ubuntu to Windows 11 as a software developer has been an interesting learning experience. Although both operating systems support software development, setting up development environments can sometimes introduce unexpected challenges.
Recently, I encountered an issue with my PHP installation while preparing my Windows machine for Laravel development.
I had previously installed PHP through Laravel Herd Lite, but I wanted to remove that installation and install PHP 8.4.1 directly on Windows.
Instead of spending more time troubleshooting graphical installation methods, I decided to use Windows Command Prompt (CMD).
Here is how I approached the problem.
1. Identifying the Existing PHP Installation
My first step was checking which PHP version was currently available on my machine.
I opened CMD and executed:
php -v
Windows returned:
PHP 8.4.0 (cli) (built: Nov 21 2024 08:18:43)
(NTS Visual C++ 2019 x64)
I wanted to replace PHP 8.4.0 with PHP 8.4.1.
However, before deleting anything, I needed to establish where the existing PHP executable was located.
I executed:
where php
The output was:
C:\Users\Backend-Nerd\.config\herd-lite\bin\php.exe
This revealed that Windows was still using the PHP executable bundled with Herd Lite.
This was an important lesson: before removing a development tool, identify where its executable is coming from.
2. Removing the Old PHP Installation
Since I no longer needed Herd Lite, I removed its installation directory.
The folder was located at:
C:\Users\Backend-Nerd\.config\herd-lite
I used the following CMD command:
rmdir /s /q "%USERPROFILE%\.config\herd-lite"
Here is what the command means:
-
rmdir: Removes a directory. -
/s: Removes the directory and its contents, including subdirectories. -
/q: Runs quietly without requesting confirmation. -
%USERPROFILE%: Represents the current Windows user directory.
Important: This deletes the Herd Lite directory and its contents, not just PHP. Make sure you no longer need its other files or services before running it.
3. Creating a New PHP Installation Directory
After removing the old installation, I decided to install PHP directly into the C drive.
I executed:
mkdir C:\php
This created a directory where I would keep my PHP installation.
Keeping development tools in clearly defined directories makes them easier to manage and troubleshoot.
4. Downloading PHP 8.4.1 Using CMD
Instead of downloading PHP manually through a browser, I used the Windows curl command.
I executed:
curl -L -o C:\php-8.4.1.zip https://windows.php.net/downloads/releases/archives/php-8.4.1-nts-Win32-vs17-x64.zip
This downloaded the official PHP 8.4.1 ZIP package.
Breaking down the command:
-
curl: Downloads files from the internet. -
-L: Follows redirects. -
-o: Specifies the output filename. -
C:\php-8.4.1.zip: Defines where the downloaded file will be saved.
I selected the following PHP build:
- PHP version: 8.4.1
- Architecture: 64-bit (x64)
- Build: Non Thread Safe (NTS)
- Compiler: VS17
For command-line PHP development, the NTS build is a suitable choice.
Official download source: https://windows.php.net/downloads/releases/archives/
5. Extracting PHP Using CMD
After downloading the ZIP package, I extracted it directly into my PHP installation directory.
I executed:
tar -xf C:\php-8.4.1.zip -C C:\php
Here is what the options mean:
-
tar: Windows utility for extracting archives. -
-x: Extract files. -
-f: Specifies the archive file. -
-C: Specifies the destination directory.
After extraction, PHP was available under:
C:\php
I could now access the PHP executable:
C:\php\php.exe
6. Creating the PHP Configuration File
PHP uses a configuration file called php.ini.
The downloaded package provides two sample configuration files:
php.ini-developmentphp.ini-production
For my local development environment, I copied the development configuration.
I executed:
copy C:\php\php.ini-development C:\php\php.ini
This created the configuration file PHP would use.
The php.ini file is important because it controls PHP settings and extensions.
For Laravel development, extensions such as OpenSSL, cURL, PDO, ZIP and Mbstring are particularly useful.
7. Adding PHP to Windows PATH
Installing PHP is not enough. Windows must also know where to find php.exe.
This is where the PATH environment variable comes in.
I used:
setx PATH "%PATH%;C:\php"
This added the PHP directory to my user PATH.
The PATH variable allows me to execute PHP commands from different directories without typing the complete path to php.exe.
A useful caution: setx can expand existing environment variables and has limitations when handling long PATH values. For an existing development machine, adding the directory through Windows Environment Variables is generally safer.
8. Verifying the PHP Installation
After completing the installation, I closed CMD and opened a new terminal.
I executed:
php -v
This allowed me to confirm whether Windows was recognizing the new PHP installation.
I also used:
where php
To identify the executable Windows was using.
The expected installation location was:
C:\php\php.exe
Lessons Learned
This experience taught me several useful lessons as a developer:
- Identify before deleting: Always establish where an executable is coming from before removing an installation.
- Understand Windows PATH: Installing software does not automatically mean Windows can execute it from every directory.
-
Use CMD effectively: Windows Command Prompt provides useful tools such as
curl,tar,mkdirandcopyfor setting up development environments. -
Keep installations organized: Having PHP in
C:\phpmakes future maintenance easier. - Verify installations: Always check the installed version and executable location before proceeding to other development tools.
Conclusion
Moving from Ubuntu to Windows 11 has taught me that becoming comfortable with a new operating system is part of becoming a better developer.
What initially looked like a simple PHP version issue turned into an opportunity to understand Windows environment variables, executable paths, ZIP extraction and command-line installation.
My next step is to configure Composer and continue setting up my Laravel development environment for SamuPOS.
If you are also transitioning from Linux to Windows for software development, I hope this experience saves you some troubleshooting time.
Useful resources
Top comments (0)