PHP: Mongo client not found

5,207

Did you type php --version or /Applications/XAMPP/xamppfiles/bin/php --version? And to which php.ini did you add that line? To /etc/php.ini or to /Applications/XAMPP/xamppfiles/etc/php.ini?

The first path always references OS-X default PHP (which is PHP5.4), the later references XAMPPs PHP (which is PHP5.5 and has a different API then PHP5.4).

So I assume that you compiled the module for PHP5.5 (XAMPP) and have added it to PHP5.4 (OS-X). That can't work at all! You'l have to add the mongo so-Path to the end of the correct php.ini-file which in your case is the one for XAMPP which (if I recall corerctly) is located at /Applications/XAMPP/xamppfiles/lib/php.ini

Share:
5,207

Related videos on Youtube

zack_falcon
Author by

zack_falcon

Updated on September 18, 2022

Comments

  • zack_falcon
    zack_falcon over 1 year

    I've installed XAMPP on my MacBook. PHP and MySQL are working fine, so I followed it up with mongo. I did the following:

    • brew install mongo (success)
    • brew install autoconf (success)
    • sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo (success)

    So far so good. I added the complete mongo.so path to the very end of `/etc/php.ini like so:

    [mongo]
    extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/mongo.so

    The Problem:

    Typing in php --version, however, returns the following:

    PHP Warning: PHP Startup: mongo: Unable to initialize module
    Module compiled with module API=20121212
    PHP compiled with module API=20100525
    These options need to match in Unknown on line 0
    PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15)

    What I Tried:

    I managed to get rid of that error above (notice: get rid), by updating OS X's PHP via the following: curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5

    I then added the following lines to .bash_profile: export PATH=~/bin:/usr/local/php5/bin:$PATH

    php -m now lists mongo as one of the modules, and it no longer produces the above error.

    However, phpinfo() does NOT have mongo, and running my webpage using mongo client gives me the following error:

    FatalErrorException Class 'MongoClient' not found

    So, I repeated the following: sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo

    And now it's telling me that my mongo is up to date:

    pecl/mongo is already installed and is the same as the released version 1.5.5

    Additional info:

    • PHP version: PHP 5.5.14 (cli) (built: Jun 28 2014 10:29:43)
    • Mongo version: MongoDB shell version: 2.6.3
    • Mongo client: 1.5.5
  • zack_falcon
    zack_falcon over 9 years
    I found it in /Applications/XAMPP/xamppfiles/etc/. That did it. Thanks!