snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.08k stars 3.18k forks source link

[Feature Request]: Add php version parameter to upgrade.php when having more php version installed #15225

Open zulasch opened 3 months ago

zulasch commented 3 months ago

Is your feature request related to a problem? Please describe.

when having multiple PHP versions installed, the upgrade is only using the default called "php" in my case I have php = 8.0xx php81 = php 8.1 php82 = php 8.2 php83 = php 8.1

so I need to specify the version for the script:

php83 upgrade.php

but the upgrade.php has hardcoded the php version.

The solution is to modify the upgrade.php script and replace all php with php8.3

here are some examples for the errors:

` Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.0.30.

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.0.30. in /home/asset/public_html/vendor/composer/platform_check.php on line 24

Something went wrong with your backup. Aborting! `

Or

`

STEP 4: Backing up database:

-- In ProviderRepository.php line 208:

Class "Laravel\Socialite\SocialiteServiceProvider" not found

Something went wrong with your backup. Aborting! `

Describe the solution you'd like

Maybe there can be a parameter like

php83 upgrade.php --php-executable /usr/bin/php83

to specify

Describe alternatives you've considered

Find & replace all php findings with php83 (or what version you need)

Additional context

No response

welcome[bot] commented 3 months ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

uberbrady commented 2 months ago

Or maybe we can just use $argv[0] - whatever you invoked the upgrade script with. Though I don't remember whether or not PHP mangles the $argv array on your behalf. Maybe there's some other environment variable or constant that specifies what the current CLI interpreter is? Well, whatever, let's say we somehow figure that out. So now we know what exact name you invoked the script with.

Then, if you said php8.3 upgrade.php, all of the instances where we say php within the script would instead be php8.3?

Then we don't even need a new command-line parameter.

uberbrady commented 2 months ago

It's not in the $argv array. But it is in a particular constant. In messing around with things, it looks like it should be:

escapeshellarg(PHP_BINARY)

Which puts single-quotes around the command (to better handle spaces in filenames, like we have on Mac and Windows).