when I try to run a server on mamp i get the error message: "Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.8".
You don't change package dependencies, that's the responsibility of the package maintainer. Either see if there is another version available that requires the same or lower version of PHP than you have installed in your environment or install the required PHP version.
It appears that MAMP Pro has support for PHP 8.1 although this question seems to have a solution without requiring the Pro version.
Related
Facing issue after downgrade the PHP version with updated version of composer,
I am trying to doing upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2 which option is given by CMD.
I tried myself with downgrade the PHP version using the Command of brew but I tried to get the solution for composer, Either it's possible to downgrade or upgrade the version of composer same like PHP.
I get the following error when running mPDF in my browser. I have just installed the latest version of mPDF on my cloud server running PHP 7.4. The requirements page for mPDF say I should be able to run this version with PHP 7.3+
I have tried to resolve the issue in composer.json but have no success. I am not able to install PHP 8.0 without upgrading the hosting which I do not want to do.
Any direction is appreciated.
Error message:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0".
If you would like to learn why the php package is required (this may sound stupid, but think about it as a requirement with a specific version), you can make use of composer-depends(1), a.k.a. why?:
$ composer why php
...
composer/semver 3.2.6 requires php (^5.3.2 || ^7.0 || ^8.0)
doctrine/annotations 1.13.2 requires php (^7.1 || ^8.0)
...
It gives an alphabetical listing of packages in your configuration and which php version they require. This should help you to spot which package requires ^8.0.0 / >= 8.0.0 to get a better understanding.
When your target platform has PHP 7.4, you can configure your project to always depend on that version. This works by specifying the platform php version as a configuration option.
Get the exact php version on your target platform, e.g. 7.4.30 (Aug 2022).
Note: PHP 7.4.x is going to end of life this year[1], consider upgrading the hosting within the next two months to 8.0 at least (if changing hosting for the PHP version is hard, consider to already go to 8.1, test your project with each version first thought, best done locally).
Then within your project configure that version as the projects target platform version:
$ composer config platform.php 7.4.30 # (1.)
# (no output)
1. replace the exemplary version 7.4.30 with your target platform version
After changing the Composer project configuration this way, you need to update the projects dependencies:
$ composer update
# ...
Now Composer will no longer infer the available version of the php platform package (the PHP version) from the environment but instead take the configured platform version. Your local PHP version is not interfering any longer to resolve the installable set of packages. Instead, the configured platform PHP version is used for the resolution.
This effectively prevents that you pull in packages that require a higher PHP version.
Commit all changes to the configuration (composer.json) and pinned versions (composer.lock) and use those to do the packaging for the deployment to the target platform.
Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?
Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question
From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.
Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.
If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app
We are using PHPCI and composer. The server which runs PHPCI is on PHP 5.3.
For a project we added the Facebook PHP SDK, using composer. It requires PHP 5.4.
Composer gets triggered by PHPCI and get executed. But because the CI server just got PHP 5.3 composer failed with the error message:
facebook/php-sdk-v4 4.0.9 requires php >=5.4.0 -> no matching package found.
This let fail my build in PHPCI, of course.
Is there a possibility to skip this requirement? Maybe by adding an option to composer.json? Or a parameter to composer.phar call?
I've found the option:
composer install --ignore-platform-reqs
Ignore platform requirements (php & ext- packages).
Alternative: Specify your projects' PHP version
You can skip the platform checks by configuring composer.json#/config/platform/php with the PHP version to use.
Composer will fetch packages based on that configured PHP version then.
So when you need to tell Composer the PHP version for your projects dependencies, you can (and should) specify the PHP version if different than the PHP version you execute composer with in your composer.json project configuration file (AKA root package):
{
"config": {
"platform": {
"php": "5.6.6"
}
}
}
Here PHP 5.6.6 version is exemplary, it could be 8.0.4 or any other PHP version.
This also documents the target (platform) PHP configuration. Additionally installed PHP extensions and library versions can be specified.
Compare: Config: platform - Composer documentation
For many commands, you can tell composer to bypass php version check, with parameter "--ignore-platform-reqs":
composer COMMAND --ignore-platform-reqs
this will bypass php version specification.
Be aware that the software may work or not: php version specification is there because somewhere in the code is needed at least the specified php version, so if you use that code the software will break.
If anything requires a specific version of PHP, it won't run in a lower version of PHP. You will properbly still recieve errors when bypassing the PHP requirement.
Btw, PHP 5.3 is no longer maintained, I would strongly recommend updating the PHPCI server.
I have installed a bitnami mac stack mainly because I require at least PHP 5.4.7 version for my project. However, I have run into an issue with composer. This is the error I get when I run:
php composer.phar install --dev
The error:
Richard-Knops-MacBook-Pro:my-project richardknop$ php composer.phar install --dev
dyld: Library not loaded: /Applications/MAMP/Library/lib/libiconv.2.dylib
Referenced from: /opt/local/bin/php
Reason: Incompatible library version: php requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
Richard-Knops-MacBook-Pro:my-project richardknop$
How to solve it?
Update your mamp installation the error clearly says that your libiconv.2.dylib is outdated.
If MAMP has no more-to-date version install apache + php via. mac-ports.
BitNami is self-contained and doesn't modify your system environment. I think that the problem was that the BitNami environment was not loaded.
Referenced from: /opt/local/bin/php
That doesn't seem to belong to a BitNami installation. For future reference the solution (I think) would have been:
Load the BitNami environment executing /Application/mampstack-5.4.x/use_mampstack
After that make sure that the environment is loaded correctly executing which php
Then execute php composer.phar install --dev