Composer installing: the json extension is missing

33,713

Solution 1

I encountered the same error, but the difference was that when I ran php -m the json module was not listed, so I just installed json PHP module using the command below:

sudo yum install php-json

the error was fixed and I was able to install composer. I was using CentOS 8 stream, PHP7.2.

Solution 2

You probably need to enable the extension in your php.ini file. To find out where that is for command line PHP, do

php --ini

You should see a line like

Loaded Configuration File: /path/to/php.ini

Open that file and look for extension=json.so. If it's there, uncomment it. If not, add it in. Now you should see json listed when you do php -m and composer should work.

Solution 3

Bug php not load extension install

create file php.ini

# /etc/php/7.2/cli/conf.d/php.ini
extension=json.so
extension=phar.so
extension=iconv.so
Share:
33,713
anindis
Author by

anindis

Thanks to everyone who answers my stupid questions. I really appreciate it

Updated on July 09, 2022

Comments

  • anindis
    anindis almost 2 years

    I wrote in Linux Terminal: curl -s https://getcomposer.org/installer | php It said:

     #!/usr/bin/env php
    Some settings on your machine make Composer unable to work properly.
    Make sure that you fix the issues listed below and run this script again:
    
    The json extension is missing.
    Install it or recompile php without --disable-json
    

    I did this: apt-get install php5-json So, I think, it's installed. But the strange thing is, when I write php -m It gives me a list without json:

    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    date
    dba
    dom
    ereg
    exif
    fileinfo
    filter
    ftp
    gettext
    hash
    iconv
    libxml
    mbstring
    mhash
    openssl
    pcntl
    pcre
    Phar
    posix
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    standard
    sysvmsg
    sysvsem
    sysvshm
    tokenizer
    wddx
    xml
    xmlreader
    xmlwriter
    zip
    zlib
    
    [Zend Modules]
    

    And when I write php5-fpm -m It sends this:

    [PHP Modules]
    bcmath
    bz2
    calendar
    cgi-fcgi
    Core
    ctype
    curl
    date
    dba
    dom
    ereg
    exif
    fileinfo
    filter
    ftp
    gettext
    hash
    iconv
    json
    libxml
    mbstring
    mcrypt
    mhash
    mysqli
    openssl
    pcre
    PDO
    pdo_mysql
    Phar
    posix
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    standard
    sysvmsg
    sysvsem
    sysvshm
    tokenizer
    wddx
    xml
    xmlreader
    xmlwriter
    zip
    zlib
    
    [Zend Modules]
    

    What am I doing wrong? I haven't found the solution at GitHub and Google