Here are the necessary steps to make PHP work with MongoDB on vanilla Mac OS X 10.8 (Mountain Lion):
-
Install Command Lion Tools for Xcode
-
Install Homebrew:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" -
Prioritize Homebrew's binaries in $PATH:
echo "export /usr/local/bin:$PATH" >> ~/.bash_profile -
Install PHP 5.4 with Homebrew:
# Setup the tap for dependencies brew tap homebrew/dupes # This is the best brew tap josegonzalez/homebrew-php # And install brew install php54 -
Install MongoDB with Homebrew
brew install mongodb -
Install "PHP Driver" for MongoDB:
sudo pecl install mongo -
Done.
Now go run some PHP-MongoDB scripts with the build-in web server from
PHP 5.4 like you normally would (don't forget to start mongod) and everything
should work.