Richard C.
—You may encounter the following error working with Laravel, or PHP applications in general: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">=
. This is common in cloud services like shared web hosts, Digital Ocean, or AWS. It is especially confusing when you already have the latest version of PHP installed.
There are a few causes of this error message:
composer.json
file is incorrect.Since Composer (the PHP dependency manager) uses the CLI version of PHP, neither your Apache PHP module version nor your Nginx PHP-FPM (PHP FastCGI Process Manager) version affects this problem. The Apache and Nginx PHP versions affect only web requests, not dependency resolution.
The solution to this configuration error differs depending on what system you are running on.
First, consider a local machine where you have full control, including a Docker container or a virtual machine.
Check the PHP version installed by running the command below in a terminal:
php -v
If your PHP version is older than the one required by Composer, you need to upgrade it. To see how to install PHP on your operating system, please follow the documentation.
Upgrading PHP, then your web server and PHP modules can be complicated. The easiest solution is to use a prepackaged Docker image for Laravel that has the latest version of PHP, such as this popular option.
If you want to upgrade PHP instead, and you are using a Debian-based server or Docker container, installation should be as simple as running the commands below:
apt install software-properties-common apt update apt install php
If you are using a RedHat-based system, the commands should be similar, but use yum
.
If the available PHP package is not recent enough, you can install PHP from the source code. To do this, download the latest .tar.gz
file. Extract it, change into its folder, configure it, and install it. Below are the commands to do this (change 8.3.4 to whatever the latest version is):
apt update apt install gcc pkg-config make libxml2 libxml2-dev sqlite3 -y curl https://www.php.net/distributions/php-8.3.4.tar.gz -o php.tar.gz tar -xvf php.tar.gz cd php-8.3.4 ./configure make install
If configure
says your SQLite version is too old, install the latest version of SQLite with the code below, then rerun the PHP configure command:
curl https://www.sqlite.org/2024/sqlite-autoconf-3450200.tar.gz -o sqlite.tar.gz tar -xvf sqlite.tar.gz cd sqlite-autoconf-3450200 ./configure make install
The latest PHP should now be available on your system.
Your computer, virtual machine, or container might have multiple versions of PHP. To ensure that you are using the latest one, you need to change your PATH environment variable. Where the operating system first finds an executable file called php
in your path is where it will call php
from, regardless of whether that version is the latest. If the latest version of PHP is installed to usr/local/bin
, ensure that the folder is first in your path.
You can do this for the root user by running the following command to alter the root .bashrc
file:
echo 'export PATH="/usr/local/bin:$PATH"' >> /root/.bashrc
Test this works by running php -v
again in a new terminal.
If your web server runs under a different user that is not root, update that user’s configuration files to point to the latest version of PHP.
You also need to ensure that your web server, most likely Apache or Nginx, is compatible with the new version of PHP and any associated modules. If the server shows errors when browsing your web application, please follow the documentation for your web server to upgrade PHP, and then restart the server.
Once PHP is upgraded, get the latest version of all your Composer dependencies and refresh the cache by running the commands below:
composer update composer global update composer dump-autoload
You might find advice online to add "platform-check": false
to your composer.json
file or run Composer with --ignore-platform-reqs
. Do not do this — it will almost certainly cause errors at runtime.
If you are certain that the version of PHP set in your composer.json
file is incorrect, you can change it to the version you want in the following field:
"config": { "platform": { "php": "7.1.0" } },
If your Composer dependencies work locally and your application runs, but you have errors on your remote web host, you need to set the correct version of PHP there. If you are using a web host where you have full control, such as AWS or Digital Ocean, you can upgrade PHP (or preferably use a Docker container with the latest PHP) as noted earlier.
If you are using a shared web host, which you can most likely configure through cPanel, you need to set PHP through the web interface.
Log in to cPanel on your host and browse to Software —> MultiPHP Manager or similar, depending on your version of cPanel.
In the PHP Selector page that opens, set the Current PHP version
field to the highest version of PHP available. If the version you want is unavailable, email your host administrator and ask them to install it.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.