I am on a shared hosting with multiple domains of my own. I bought a new one and specifically for it I was required to use php 8.2 or above. Using MultiPHP manager I did set it to PHP 8.2 (ea-php82) and run the php -v command in the domain’s directory and it said:
PHP 8.2.18 (cli) (built: Apr 18 2024 09:00:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.18, Copyright (c) Zend Technologies
Now when I run the composer command composer install I get a bunch of errors saying I am using 8.1So I entered these commands:
[foo@foo foo.com]$ which php
/usr/local/bin/php
[foo@foo foo.com]$ /usr/local/bin/php -v
PHP 8.2.18 (cli) (built: Apr 18 2024 09:00:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.18, Copyright (c) Zend Technologies
[foo@foo foo.com]$ which composer
/opt/cpanel/composer/bin/composer
Then as required I enter this command and this happens:
[foo@foo foo.com]$ /usr/local/bin/php /opt/cpanel/composer/bin/composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires php ^8.2 but your php version (8.1.28) does not satisfy that requirement.
Problem 2
- laravel/framework is locked to version v11.4.0 and an update of this package was not requested.
- laravel/framework v11.4.0 requires php ^8.2 -> your php version (8.1.28) does not satisfy that requirement.
Problem 3
Now if last possible thing that I tried was to use ignore platform requirements and that resulted in an error too:
[foo@foo foo.com]$ /usr/local/bin/php /opt/cpanel/composer/bin/composer install --ignore-platform-reqs
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Error
Call to undefined method ReflectionFunction::isAnonymous()
at vendor/laravel/framework/src/Illuminate/Container/Container.php:680
676▕ */
677▕ protected function getClassForCallable($callback)
678▕ {
679▕ if (is_callable($callback) &&
➜ 680▕ ! ($reflector = new ReflectionFunction($callback(...)))->isAnonymous()) {
681▕ return $reflector->getClosureScopeClass()->name ?? false;
682▕ }
683▕
684▕ return false;
+3 vendor frames
4 [internal]:0
IlluminateFoundationApplication::IlluminateFoundation{closure}()
+6 vendor frames
11 artisan:13
IlluminateFoundationApplication::handleCommand()
Error
Call to undefined method ReflectionFunction::isAnonymous()
at vendor/laravel/framework/src/Illuminate/Container/Container.php:680
676▕ */
677▕ protected function getClassForCallable($callback)
678▕ {
679▕ if (is_callable($callback) &&
➜ 680▕ ! ($reflector = new ReflectionFunction($callback(...)))->isAnonymous()) {
681▕ return $reflector->getClosureScopeClass()->name ?? false;
682▕ }
683▕
684▕ return false;
+4 vendor frames
5 artisan:13
IlluminateFoundationApplication::handleCommand()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
[foo@foo foo.com]$
Any solutions?
I have tried using MultiPHP manager in cPanel. I have tried giving different php version paths. I have tried using the composer’s ignore platform requirements command as well.
Hasan Niazi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.