I have asked my hosting provider to switch the operating system on my server from Centos to Ubuntu. Upon downloading all my files from GitHub and running “composer install” I am getting the following error in terminal:
Deprecation Notice: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in /usr/share/php/Composer/Downloader/GitDownloader.php:223
Deprecation Notice: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in /usr/share/php/Composer/Downloader/SvnDownloader.php:132
After this composer quits so I need to be able to resolve this not worked around it.
Already tried solutions:
- Uninstall and re-install composer.
- Upgrade, update, and install commands attempted.
- A fresh install of Laravel in case of corruption on Git clone.
6
Answers
How to solve it
Put parenthesis surrounding
What is the error
If you’d write something like this:
PHP would previously interpret it like this:
PHP 8 will make it so that it’s interpreted like this:
source: https://stitcher.io/blog/new-in-php-74
If
composer self-update
is not solve your problem, re-installing composer is best way.https://getcomposer.org/download/
My composer also gave these errors and self-update not worked.
While working on a new project this morning, I encountered a similar error. And my solution : if an expression has . with +,- etc. you must add parenthesis,
to
echo ‘Total’ . 5 + 5;
Deprecated: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in … on line …
From PHP 8 and later, this will be evaluated as ‘total’ + (5 + 5), with the + and – operators taking higher precedence.
upgrade composer using this command
composer self-update
happy coding
You can rename the composer.phar file with composerOld.phar and download new file manually from the official site and put it over there.
It will work.