26

Just updated to saucy 13.10 and json_encode is missing from the bundled php. json doesn't appear in the phpinfo() output and i'm getting this error in my app:

PHP Fatal error:  Call to undefined function json_encode()

Anyone else experiencing this or know the fix?

2 Answers 2

37

Install php5-json:

sudo apt-get install php5-json

This used to be provided by php5-common but that has changed in Saucy. No idea why and seems like a silly thing to do but it's very simple to fix.

After the installation, make sure to also restart the Apache2 server:

sudo service apache2 restart
3
  • 6
    thank you. I found this explanation...funny stuff: iteration99.com/2013/php-json-removed-from-php-5-5 Oct 18, 2013 at 22:58
  • 2
    Oh god, it's that?! I've read about that nonsense ages ago but never dreamed anybody would feel that it was legally contrary to the PHP license. What a waste of time.
    – Oli
    Oct 18, 2013 at 23:08
  • 1
    @AlexButum It's still on iteration99.com - it's just not available at the moment. I'd guess it's a static site (eg Jekyll) that hasn't been rebuilt properly.
    – Oli
    Dec 20, 2013 at 14:03
5

When you install this package, if you don't see php5-fpm restart post install, don't forget to do the following:

sudo service php5-fpm restart
1
  • Dude, thank U very much - only because Your answer I can use php-json lib, even after restart/reload nginx didn`t load this lib via fpm. Thx a lot. Jan 28, 2014 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .