Unable to set up laravel project with composer because of php version issue

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.

New contributor

Hasan Niazi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật