Make sure your php version matches what the version of laravel you are using requires. Different laravel versions require a different minimum php version.
Had the same issue, forgot to disable php 7.0 before enabling 7.2 module in apache (nothing changes in apache and no errors are given if you just enable 7.2 without disabling 7.0 first).
Also handy if you are on Ubuntu/Debian:
"update-alternatives --config php"
lets you set the default php version for CLI, this way you can jump back and forth between php versions to use as default.
If you have shell access, check out your $PATH. Mine was picking up an old version of php.
whereis php
echo $PATH
I found the right version of php here: /opt/php71/bin
so I add this line to the end of my .bashrc
export PATH=/opt/php71/bin:$PATH
Now composer doesn't error.
and php artisan runs great!
:-D
PS. The version of php that you're using in the shell may be different from the version used to serve your site. That can be fixed in cpanel's php selector.
Hi, Facing same issue despite that I have same version of php 7.1.5 on both CLI and apache server.Iam using laravel 5.4.Iam .Any suggestions will help.
I have the same problem and I think it's a php version incompatibility between the composer version and the server version.
In my composer I have php 7.1 version and my server has 5.6 php version. When I change the server version to 7.1, delete the composer.lock, delete the vendor directory and regenerate the vendor, all starts to work another time.