2 minutes
Php Version Switcher: The Structure
This article is part of my #100DaysOfCode and #100DaysOfBlogging challenge. R1D10
This is part three of a series of articles about the PHP Version Switcher.
- Part One: Php Version Switcher: PowerShell Module
- Part Two: Php Version Switcher: PowerShell Naming Convention
- Part Four: Php Version Switcher: The Function
Today I will talk about the structural concept of the PHP Version Switcher.
On Windows you need to add the path of your PHP location to the system environment variable PATH
. Switching in-between different PHP versions would mean to also to update the PATH
each time. Furthermore, if Apache is supposed to be running the same PHP version, the LoadModule
must be updated to the “new” PHP location. That’s just laborious and not fun at all. But PHP Version Switcher to the rescue! 🤹🏼♂️
Directory structure
Everything related to my webserver goes into the directory C:\webserv
. There’s Apache, CouchDB, Elasticsearch, Ruby, sendmail etc. and the latest versions of PHP 5.6 through 7.4 (the latter being a non-stable snapshot).
Symlink
As you might have noticed, among the many PHP directories, there is on just plain called php
. This is a symbolic link to the currently set PHP version. This directory is also what I put into my PATH
and httpd.conf
.
The php_shared
folder contains files common among PHP installations. Currently it only houses the cacert.pem
.
Tasks of the PHP Version Switcher
The pvs
now does three things:
- Remove the current symlink
C:\webserv\php
. - Create a new symlink referring to the provided PHP version.
- Restart the Apache service.
Et voilà, the machine is running a different PHP version.
How this script looks in detail, I will discuss in one of the following posts.