I am trying to install mpdf using composer, but when I try command_prompt "composer require mpdf/mpdf" in my project folder, I get version 6.1 installed instead of 7.x. Any suggestions?
Windows 11
XAMPP v3.3.0
Any help appreciated!
command prompt screen shot
This can work like this because of php version installed locally. latest version of mpdf or its dependencies can require the specific version of php or its extensions or smth else. If you're not going to run your code locally, you can cpecify target php and exts versions int you composer.json like this:
{
"require": {
"php": "~7.4.0",
"ext-gd": "*",
"ext-mbstring": "*"
}
}
You may not get the latest lib version but you will get version that will work on your target system
This question already has answers here:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0"
(22 answers)
Closed 2 days ago.
I am getting this error with Laravel 9, I have PHP 8.1.7 installed
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
I can see other have asked the question, bit non of the solutions seem to be working
TIPS
Add this lines in composer.json file:
{
"config": {
"platform-check": false
}
}
Or set the version:
{
"config": {
"platform": {
"php": "7.1.0"
}
}
}
And run composer dump-autoload
I had the same problem and it was because I configured a version of PHP 8.1 on the command-line while I kept the PHP module at 8.0.
So PHP_VERSION_ID gave me 80020, while php -v gave me 8.1.7.
It reminded me to reconfigure the PHP Module to PHP version 8.1:
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2
And then everything worked like intended.
Reference:
phpinfo() and php -v shows different version of PHP
If #eril answer did not help you by disabling old PHP version
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2
also check composer using a correct version of PHP
composer -vvv about 2>&1 | grep "PHP"
if composer about already shows a correct version of PHP,then check to see the real PHP binary path that composer is using by putting PHP_BINARY inside vendor/composer/platform_check.php like this:
if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'You are running ' . PHP_VERSION . ' located at: ' . PHP_BINARY;
}
in my case, an old version of php-fpm was enabled.
a2disconf php8.0-fpm
a2enconf php8.1-fpm
sudo systemctl restart apache2
If you install composer globally, just run composer global update. It will solve your problem.
Open your composer.json and check where the 'require' block says 'php'. It has an expression that can put a constraint on the PHP version or version range that is allowed for all of your projects' dependencies.
A good value would be to use the one below. Change it and run composer update afterwards.
"require": {
"php": "^8.0|^8.1",
Contrary to the composer.json which laravel 9 ships with:
"require": {
"php": "^8.0.2",
(see laravel 9 composer.json in the official repository: https://github.com/laravel/framework/blob/9.x/composer.json)
Don't change any thing in your application. In your shard hosting, go to cPanel and find/search Multi PHP Manager. Select your domain or sub domain (whatever you are working with), from dropdown list select PHP 8.1 and apply.
Now find/search PHP Selector and for Current PHP Version select 8.1.
in the same window go to Extensions and enable pdo_mysql.
You are good to go.
Your Composer dependencies require a PHP version ">= 8.1.0"
I had this same issue while I downgraded my php to v7.4 from 8.1. I somehow messed up with php7.4-fpm mod. However, when I again tried to upgrade my php v8.1 composer started to complain about that error.
I simply removed my both php versions that's 7.4 and 8.1 and re-installed only 8.1, which fixed my issue.
To remove, here are the steps I followed....
sudo apt-get purge php8.*
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.1
and then finally,
sudo service apache2 restart
If you are simply using git to version your Composer dependencies for a deployment, consider the --ignore-platform-reqs flag.
For more info, see Options at https://getcomposer.org/doc/03-cli.md#install-i
composer update --dry-run --ignore-platform-reqs
--ignore-platform-reqs: ignore all platform requirements (php, hhvm, lib-* and ext-*) and force the installation even if the local machine does not fulfill these. See also the platform config option.
If you are operating on nginx server, It's likely the php-fpm8.1 is not active.
Try to:
sudo systemctl status php-fpm8.1.service
Depends on the status of the php-fpm version, you can act, and if it's stopped, you may want to do the following:
sudo systemctl enable php-fpm8.1.service
sudo systemctl start php-fpm8.1.service
Then double-check the status, and if it's active. You're good to go.
Note: This applies to any php-fpm version, not just 8.1.
Hope this help!
if you use XAMPP, check that the PHP version of your XAMPP is the correct one (the same one you have on your computer). Otherwise, download and install the correct version of XAMPP
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
I faced the same problem.
Just go to Cpanel.
Then PHP Selector
and finally, change PHP version
If you are in the process of upgrading Laravel versions and you switch to the version which requires PHP8 (8 or 9 cant remember)
And you also switch PHP versions,
you need to restart your
php artisan serve
in my case everything is fine
composer.json is fine
php 8.1 is installed
I am using nginx I restart nginx but I found that my configuration is wrong it looks like this
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
so the correct configuration is
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
Hope this will help someone
I had the exact issue.
I added the line phpversion() and found that the version was different from what was set for my apache.
I enabled the php8.1-fpm with this command:
sudo a2enconf php8.1-fpm
After restarting Apache I got it working.
It's just until I find how to solve it but it's working
So that's what i've done :
download php 8.1.9 (nts)
extract it in bin/php/ (i use Laragon)
move php 7.14.19 in a new folder(just for preventing)
and rename my php 8 folder to php 7 folder name
it's still working
Just find the php folder of your server
I have face this problem to install maatwebsite/excel on laravel 8. How can I fix it?
NB: PHP version running 8.
I solved the problem with
I just enable PHP gd extension from php.ini file
installing PHP package PhpSpreadsheet
The problem is about Laravel Excel requirements. It seems PhpSpreadsheet: ^1.15 is not installed. Here is the list of requirements for Laravel-Excel 3.1,
PHP: ^7.2\|^8.0
Laravel: ^5.8
PhpSpreadsheet: ^1.15
PHP extension php_zip enabled
PHP extension php_xml enabled
PHP extension php_gd2 enabled
PHP extension php_iconv enabled
PHP extension php_simplexml enabled
PHP extension php_xmlreader enabled
PHP extension php_zlib enabled
Make sure these are installed and enabled on your php.ini. Also make sure your php version on composer.json is set like this:
"require": {
"php": "^7.2|^8.0",
},
Instead of something like this "php": ">=7.2". Check this out for more information. Please let me know if it worked.
I just want share another answer related here. If you run on unix (linux), try install php-gd using command line. Try check other answer related to your system.
sudo apt-get update
sudo apt-get install php8.0-gd
related:
How to install PHP GD in Ubuntu
install php-gd ext on Debian
Issue with enabling GD in PHP
If you using windows. Use this command.
composer require maatwebsite/excel --ignore-platform-reqs
This problem happen only on php 8.x! perhaps on lastest php 7. The problem same as above and still failed even php-gd is active. When type
composer require maatwebsite/excel
the error still the same. When checking using
php -i
(basicly same as phpinfo in console). We can see php gd is active. This answer is not recommended at the moment. Fixed still on the way related to this issue.
related link:
https://github.com/Maatwebsite/Laravel-Excel/discussions/3191
PHP8 is supported, make sure to use 3.1.30 of the package as mention above. To see other issue, please read this link.
https://github.com/Maatwebsite/Laravel-Excel/issues/2936
I solved using
Enable zip and gd extension in php.ini
or install using sudo apt-get install php8.0-gd
sudo apt-get install php8.0-zip
use composer require maatwebsite/excel:^3.1 -W
-W is for with-all-dependencies
I have just used composer require maatwebsite/excel -W --ignore-platform-req=ext-zip and this has worked for me on linux ubuntu 20 with php 8.1
delete composer.lock (json)
then run below command
composer require phpoffice/phpspreadsheet
composer require maatwebsite/excel
it is working
In my Laravel application I am trying to install a package that depends on the Imagick PHP extension. The error is below:
spatie/pdf-to-image 1.8.2 requires ext-imagick * -> the requested PHP extension imagick is missing from your system.
However 1&1 explicitly states that this is already installed under /usr/bin/convert according to the following link:
https://www.ionos.co.uk/help/hosting/using-php-for-web-projects/using-imagemagick/
Is there a way to tell the composer.phar within my project thaat the package exists elsewhere?
Possible answer here:
Link
As a package consumer you can set or override the install path for a package that requires composer/installers by configuring the installer-paths extra. A useful example would be for a Drupal multisite setup where the package should be installed into your sites subdirectory. Here we are overriding the install path for a module that uses composer/installers:
{
"extra": {
"installer-paths": {
"sites/example.com/modules/{$name}": ["vendor/package"]
}
}
}
I was installing via brew (on mac) and had problems.
$ pecl install imagick did it for me
On Ubuntu (and other linux distros with apt), the command to install this extension is
sudo apt install php-imagick
I am trying to require "ext-SimpleXML": "^7.1" in my composer.json and I am using travis as my testing framework. Locally everything works fine but on travis (when using composer install) I always get the error message:
The requested PHP extension ext-simplexml ^7.1 has the wrong version (0.1) installed. Install or enable PHP's simplexml extension.
Does anyone know how I can update or tell travis to install/use the correct version? I already tried it with sudo apt-get install php-xml without success.
Try use the line below.
"ext-SimpleXML": "*"
https://getcomposer.org/doc/01-basic-usage.md#platform-packages
Most of PHP extensions do not have own versions. They are fixed to a specific PHP build. Few are a thin shims to system libraries and the shims versions are meaningless.