JSON Extension is Always Available in PHP 8.0

JSON is a text-based data format that commonly used to store or transmit data objects between systems. JSON is widely used in web applications. In versions prior to PHP 8.0, it was possible to compile PHP without the JSON extension using --disable-json option:

./configure --disable-json

Since PHP 8.0, the JSON extension is always included in PHP core. It means that functions like json_encode or json_decode will be always available without worrying whether or not JSON extension is installed.

If project uses PHP 8.0 or later and composer.json file has ext-json in the require section, then we can remove ext-json from a list because JSON extension is already included in PHP since 8.0.

{
  "require": {
    "php": "^8.0",
    "ext-json": "*"  This line is no longer necessary
  }
}

Leave a Comment

Your email address will not be published. Required fields are marked *