svandragt / wmm

Sane WordPress local environment
0 stars 0 forks source link

multiple concurrent php versions #22

Closed svandragt closed 1 year ago

cameronterry commented 1 year ago

Before I forget - it would be good if this is tied into the [sudo] update-alternatives --config php option available within Ubuntu. Apologies in advance if you know this, the rest is background information in case you do not.

As this means you can quite effortlessly switch between (if installed) multiple PHP versions without needing to adjust configuration files. Combined with the PHP FPM sock approach, i.e. this in NGINX;

upstream php {
    server unix:/var/run/php/php-fpm.sock;
}

Then the update alternatives will update both the PHP CLI and PHP FPM, as the /var/run/php/php-fpm.sock file is symlink controlled.

I cannot recall off the top of my head if you need to run sudo nginx -s reload / sudo service nginx reload, but I suspect you do as it'll likely store the contents of that file in memory when it is first loaded (like the rest of NGINX configurations). Probably something similar if Caddy and PHP FPM are communicating with each other.

Does come a bit undone if you have multiple developments all with individual PHP versions requirements, as this would change the version for all of them at once (unless the configuration used the version specific php8.0-fpm.sock file); VVV works in this manner for NGINX, but for the PHP CLI it relies on update-alternatives --config - which you often end up needing if you working across multiple PHP versions for different setups and need to run WP CLI commands for instance.

svandragt commented 1 year ago

Multiple PHP versions are already supported by changing this script and setting this line, on which other scripts depend: https://github.com/svandragt/wmm/blob/main/scripts-available/10-php80.sh#L2 Dependencies: https://github.com/search?q=repo%3Asvandragt%2Fwmm+PHP_VERSION&type=code It doesn't use update-alternatives because only one version is installed.

@cameronterry Do you require multiple PHP versions in the same project? if so that can be the focus of this issue.

cameronterry commented 1 year ago

@svandragt yes - on Dark Matter Plugin, especially for bug fixes, it's more useful to be able to jump between multiple versions within the same project.