Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deicool's avatar

PHP error

Hello

I am a newbie.

I am getting the following error inspite of php8.2.0 installed on my server:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0".

"php -v" returned the following details:

ubuntu@ip-172-31-45-253:/var/www/html/example-app$ php -v
PHP 8.2.0 (cli) (built: Dec 10 2022 10:52:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

Any ideas?

0 likes
31 replies
deicool's avatar

@Sinnbeck

ubuntu@ip-172-31-45-253:/var/www/html/example-app$ php -v

PHP 8.2.0 (cli) (built: Dec 10 2022 10:52:42) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.0, Copyright (c) Zend Technologies with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

deicool's avatar

@Sinnbeck

/usr/local/bin/composer

(Composer version 2.5.1 2022-12-22 15:33:54)

deicool's avatar

@Sinnbeck

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/sail ................................................................................................................................ DONE
  laravel/sanctum ............................................................................................................................. DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/collision ........................................................................................................................ DONE
  nunomaduro/termwind ......................................................................................................................... DONE
  spatie/laravel-ignition ..................................................................................................................... DONE

81 packages you are using are looking for funding.
Use the `composer fund` command to find out more!


Sinnbeck's avatar

@deicool yay it worked. Not sure why composer isn't picking it up automatically though

deicool's avatar

@Sinnbeck

But I am getting the same error in browser:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
Sinnbeck's avatar

@deicool that means that you set your webserver to use the wrong php version. Which webserver is it?

jlrdw's avatar

@Sinnbeck what version requires 8.2.0? Latest is 8.0.2 requirement, or what am I missing.

deicool's avatar

@Sinnbeck

Its apache2

Server version: Apache/2.4.41 (Ubuntu)
Server built:   2021-07-05T07:16:56

If I type the ipaddress in the browser now, I am getting:

[TXT]	README.md	2022-12-19 17:35	4.0K	 
[DIR]	app/	2022-12-19 17:35	-	 
[   ]	artisan	2022-12-19 17:35	1.6K	 
[DIR]	bootstrap/	2022-12-19 17:35	-	 
[   ]	composer.json	2022-12-23 06:27	1.8K	 
[   ]	composer.lock	2022-12-23 06:12	280K	 
[DIR]	config/	2022-12-19 17:35	-	 
[DIR]	database/	2022-12-19 17:35	-	 
[DIR]	lang/	2022-12-19 17:35	-	 
[   ]	package.json	2022-12-19 17:35	286	 
[   ]	phpunit.xml	2022-12-19 17:35	1.1K	 
[DIR]	public/	2022-12-19 17:35	-	 
[DIR]	resources/	2022-12-19 17:35	-	 
[DIR]	routes/	2022-12-23 06:32	-	 
[DIR]	storage/	2022-12-19 17:35	-	 
[DIR]	tests/	2022-12-19 17:35	-	 
[DIR]	vendor/	2022-12-23 06:12	-	 
[   ]	vite.config.js	2022-12-19 17:35	263	 
Tray2's avatar

@deicool There are different php.ini files for cli and webserver, so my guess is that apache uses the wrong path to php and thus the php.ini.

Just create a index.php file in your document root with the following.

<?php
  phpinfo();

And then open it in your browser. It will tell you what version of php Apache is using.

1 like
Tray2's avatar

@deicool And the dependency requires

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0".

So that is the problem, make sure you have the correct path in your httpd.conf file.

deicool's avatar

@Tray2

There is no httpd.conf in my apache installation. It is apache.2conf. And there is php8.2.conf, php8.2.load in mods-enabled directory.

deicool's avatar

@Tray2

works. thank you.

One more question:

How do I now create a simple Controller and integrate with Laravel?

Sinnbeck's avatar

@deicool Maybe try installing it again, to see if you can get apache2 to pick it up.

sudo apt install php8.2-common

There might also be some way in apache to set which php version to use for a specific site, but I dont use apache2 myself, to I dont know how.

deicool's avatar

@Sinnbeck

I can see the following files in apache mods-enabled directory:

access_compat.load  authn_core.load  authz_user.load  deflate.load  fcgid.conf   mime.load         negotiation.load  proxy.load       rewrite.load        ssl.conf
alias.conf          authn_file.load  autoindex.conf   dir.conf      fcgid.load   mpm_prefork.conf  php8.2.conf       proxy_fcgi.load  setenvif.conf       ssl.load
alias.load          authz_core.load  autoindex.load   dir.load      filter.load  mpm_prefork.load  php8.2.load       reqtimeout.conf  setenvif.load       status.conf
auth_basic.load     authz_host.load  deflate.conf     env.load      mime.conf    negotiation.conf  proxy.conf        reqtimeout.load  socache_shmcb.load  status.load

Sinnbeck's avatar

Unless you are actually trying to learn how to set up a webserver, I can highly recommend taking a look at ploi.io. It sets up the server for you and changing php versions is just a few clicks in the interface. You still need to have the server hosted at digitalocean, hetzner or similar, but it is well worth it! Especially if you plan to run multiple sites.

deicool's avatar

@Sinnbeck

Nope. I have to have the webserver on my dedicated aws server. And I am not new to apache.

Sinnbeck's avatar

@deicool Ok cool. Then get apache to use the correct php version :) Maybe try google. I havent used apache2 for 4-5 years, so I cant remember much. I use nginx only now :)

1 like
mphoola's avatar

I had a similar error today. updating the php version to 8.2 or 8.3 was not working. only to find out that the apache config for the server was using php 8.1 as its default php.

So in case someone else faces this error in the future, consider checking which php version is your apache/nginx actually using.

Codes09's avatar

BTW Saw this behaviour on local after upgrading PHP version. A simple restart of php artisan serve solves this for a local dev environment. Same might apply to a webserver if you've switched out php versions and the old process is still running without restart.

Please or to participate in this conversation.