PHP 8.0 : Json extension is now always available
28, September 2020

PHP 8.0 comes with json extension statically built into it. So functions like json_encode(), json decode() can be always used without worrying about whether user has installed json extension or not.


Little Bit of History:

json support was added in PHP 5.2 back in 2006.

The codebase of the extension had a specific license That was not compatible with "Free and Open Source Software (FOSS)" Licence. As a result few linux distribution such as Debian, Ubuntu, Fedora did not ship PHP with json extension built in. There was a flag to disable json extension during PHP build. Json extension was loaded as shared library.

As several linux distro users faced problem to use json on default php setup, there was a demand to release a "Free" version of json parser. Remi Collet, a core contributor, wrote a json-parser that has PHP license. The extension could be installed via PECL. That extension had same functionality as json.org one, so issue was partially solved.


PHP 7 era:

Then in PHP 7, another core contributor, Jakub Zelenk spend his time to write jsond which was Drop-in alternative for the standard JSON extension. Even if jsond was enabled in php by default, It was still possible to disable json extension with ./configure --disable-json. So, PHP Core libs couldn't rely on json if needed becuase it may not be available. Userland codebases needed to check if(extension_loaded('json')) before using any json functions.


Long Live PHP 8:

In current web development space, json is hugely widespread. Json can be found almost every tech stack. PHP devs did not overlook the situation. As there are no more licence issue, It is the best time to embrace json into core and ship it bundled by default. So, from now on, each PHP distribution has json (we can't disable it).

As a benefit:

  • Core Libs can now use json functionality if they want
  • Userland can use json without worrying about extension loaded or not.


RFC: https://wiki.php.net/rfc/always_enable_json


Write comment about this article: