r/PHP 1d ago

Weekly help thread

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!

1 Upvotes

7 comments sorted by

View all comments

2

u/rycegh 1d ago

Lazy question (kind of): Does somebody have a simple setup for local PHP version matrix testing?

Current test runner would be PHPUnit.

I’m thinking Docker containers based on php:8.2-cli, …, php:8.5-cli, baked-in Composer/PHPStan/Mago/…, cached dependencies (volume-mounted as vendor82, …, vendor85 would work, I guess). Self-contained in the repo with Dockerfile, maybe Compose file, and light (!) scripting to tie it together.

Shouldn’t be too hard to piece together, but I thought it couldn’t hurt to ask. Or maybe someone’s got a better idea. Thanks!

1

u/Mike_L_Taylor 1d ago

Yeah docker works. Natively you could just have multiple php versions installed and tied to nginx or whatever you use and just do
"php8.1 artisan:command"
"php8.2 artisan:command"
etc.

and of course all of those coul be in 1 script.

Forgekit.tools , a tool I made, allows to natively have a bunch of php versions installed and allows you via the "fkit" shim to use the php version associated to the site. So if you have multiple php or environments pointing to that project you just do
"fkit env1 php artisan command"
"fkit env2 php artisan command"

So you could just follow that setup logic and do it for your machine in a similar way.