📜 ⬆️ ⬇️

Php json has been removed from php 5.5?

Perhaps some of you upgrading php to version 5.5 on your Linux machines, found a good part of your applications down due to a fatal error similar to this:

PHP Fatal error: Call to undefined function json_encode() 

Why did this happen in the free translation of the article “Has PHP JSON been removed in PHP 5.5?”,
under the cut.

What's happening?



Crocford ( Douglas Crockford ) JSON - a widely used data exchange format, found itself in licensing conflict with PHP in Linux distributions due to the strings in the licensing agreement of the first, which reads:
')
“The Software shall be used for Good, not Evil.”

In this, the JSON license does not match with the freedom number zero from the Free Software Foundation:
“The program for any purpose.”
(the program can be freely used for any purpose)


Although it may seem insignificant, the author json.org "politely" refuses to amend the license. The answer was to remove the standard PHP JSON extension in PHP 5.5rc2 on Debian, Fedora, and other distributions.

Until the package manager of your Linux distribution begins to provide the json extension as a package, the json functions may not be available. Any code using these standard functions will result in errors:

 PHP Fatal error: Call to undefined function json_encode() PHP Fatal error: Call to undefined function json_decode() 

(comment of translator: in ubuntu server 13.10 PHP 5.5.3-1ubuntu2 the JSON extension comes with a separate php5-json package)

The solution is for those affected.


JSON in PHP will be provided by other extensions in due time and hopefully it will be transparent to the end user, but if you don’t want to wait for the update and you are affected by this problem, you can install the PECL JSON-C extension from Remi (jsonc by Remi Collet) which uses the json-c library.

My solution for CentOS 5.9 was to install the PECL JSON-C extensions from the Remi repository for YUM:
 yum --enablerepo=remi install php-pecl-jsonc 


For Debian distros, a third-party repository from Ondřej may be useful (approx. Translator: I think this is about it )

If you installed the extension manually, do not forget to add it to php.ini

References:
bugs.php.net/bug.php?id=63520
github.com/remicollet/pecl-json-c

Original article

www.json.org/license.html
www.gnu.org/philosophy/free-sw.html

From translator

The article is dated August 9 and is not really relevant (for example, for a fresh Ubuntu, there is a php5-json package). I decided to publish this translation for two reasons:
  1. I want to notify those whom it concerns, so as not to be like mine. Upgrading your server to Ubuntu 13.10 spent some time looking for the reasons for the demolition of a part of the functional and finding a solution;
  2. The very reason for removing json from php seemed to me rather ... Interesting, if I may say so. And the reason for the deletion and the existence of the above line in the json.org license;

Source: https://habr.com/ru/post/198312/


All Articles