I had installed php 5.6.27 when I installed LAMP on my machine. A few days back I installed php 5.3.29 alongside my previous php version. After that when I tried running composer update on a symfony2 project, I get an error:
Fatal error: Uncaught Error: Call to undefined function Composer\Console\json_decode() in /usr/share/php/Composer/Console/Application.php:145
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Application.php(120): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/share/php/Composer/Console/Application.php(99): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /usr/bin/composer(44): Composer\Console\Application->run()
#3 {main}
thrown in /usr/share/php/Composer/Console/Application.php on line 145
I have currently enabled php 5.6.27 using sudo a2enmod php5.6
command. On my browser the output of phpinfo() displays php version as 'PHP Version 5.6.27-1+deb.sury.org~xenial+1'. Also the php-json module is enabled as shown in the screenshot below
In the terminal the output of php -v
is:
PHP 5.6.27-1+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
As suggested in the answer on this post PHP Fatal error: Call to undefined function json_decode(), I've tried running sudo apt-get install php5-json
, but it outputs:
sudo: unable to resolve host utkarsh
[sudo] password for lenovo:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php5-common' instead of 'php5-json'
php5-common is already the newest version (5.3.2-1ubuntu4).
0 upgraded, 0 newly installed, 0 to remove and 50 not upgraded.
After this I've restarted the apache2 server but on running composer update
it still gives me same error.
All help is appreciated.