Commit 31789660 authored by Ondrej Sury's avatar Ondrej Sury

Merge tag 'upstream/1.2.0'

Upstream version 1.2.0

# gpg: Signature made 2016-12-01T11:18:24 CET
# gpg:                using RSA key 0x0C99B70EF4FCBB07
# gpg: Good signature from "Ondřej Surý <>" [ultimate]
# gpg:                 aka "[jpeg image of size 3934]" [ultimate]
# gpg:                 aka "Ondřej Surý <>" [ultimate]
# gpg:                 aka "Ondřej Surý <>" [ultimate]
# Primary key fingerprint: 30B9 33D8 0FCE 3D98 1A2D  38FB 0C99 B70E F4FC BB07
parents 57989f21 b30fb07c
MongoDB Driver for PHP
Hannes Magnusson, Jeremy Mikola, Derick Rethans
.PHONY: coverage testclean package package.xml
DATE=`date +%Y-%m-%d--%H-%M-%S`
MONGODB_VERSION=$(shell php -n -dextension=modules/ -r 'echo MONGODB_VERSION;')
MONGODB_MINOR=$(shell echo $(MONGODB_VERSION) | cut -d. -f1,2)
MONGODB_STABILITY=$(shell php -n -dextension=modules/ -r 'echo MONGODB_STABILITY;')
COMPOSER_ARGS=update --no-interaction --prefer-source
@echo -e "\t$$ make vm"
@echo -e "\t - Launches VMs for running multiple MongoDB variations"
@echo -e "\t$$ make list-servers"
@echo -e "\t - Lists running servers, and their URIs"
@echo -e "\t$$ make test-bootstrap"
@echo -e "\t - Starts up MongoDB through mongo-orchestration"
@echo ""
@echo -e "\t$$ make coveralls"
@echo -e "\t - Creates code coverage report using coveralls"
@echo -e "\t$$ make coverage"
@echo -e "\t - Creates code coverage report using gcov"
@echo ""
@echo -e "\t$$ make composer"
@echo -e "\t - Installs test dependencies using composer"
@echo ""
@echo -e "\t$$ make distcheck"
@echo -e "\t - Builds the archive, runs the virtual tests"
@echo ""
@echo -e "\t$$ make package.xml"
@echo -e "\t - Creates a package.xml file with empty release notes"
@echo -e "\t$$ make package"
@echo -e "\t - Creates the pecl archive to use for provisioning"
@echo -e "\t$$ make test-virtual"
@echo -e "\t - Provisions some VMs, installs the pecl archive and executes the tests"
@if test -e $(top_srcdir)/coverage; then \
echo "Moving previous coverage run to coverage-$(DATE)"; \
mv coverage coverage-$(DATE); \
lcov --gcov-tool $(top_srcdir)/ --capture --directory . --output-file .coverage.lcov --no-external
lcov --gcov-tool $(top_srcdir)/ --capture --derive-func-data --directory . --output-file .coverage.lcov --no-external
coverage: mv-coverage lcov-local
genhtml .coverage.lcov --legend --title "mongodb code coverage" --output-directory coverage
coveralls: mv-coverage lcov-coveralls
coveralls --exclude src/libbson --exclude src/libmongoc --exclude src/contrib --exclude lib --exclude tests
@command -v composer >/dev/null 2>&1; \
if test $$? -eq 0; then \
composer $(COMPOSER_ARGS) ;\
if test -d $(LIB_PATH); then \
composer $(COMPOSER_ARGS) --working-dir $(LIB_PATH) ;\
fi \
elif test -r composer.phar; then \
php composer.phar $(COMPOSER_ARGS); \
if test -d $(LIB_PATH); then \
php $(top_srcdir)/composer.phar $(COMPOSER_ARGS) --working-dir $(LIB_PATH) ;\
fi \
else \
echo "Cannot find composer :("; \
echo "Aborting."; \
exit 1; \
@command -v vagrant >/dev/null 2>&1 || { echo >&2 "Vagrant needs to be installed to run vms"; exit 1; }
@vagrant up ldap mo
php scripts/list-servers.php
php scripts/start-servers.php
distcheck: package test-virtual
test-virtual: package
sh ./scripts/ freebsd
sh ./scripts/ precise32
sh ./scripts/ precise64
testunit: composer
@command -v phpunit >/dev/null 2>&1; \
if test $$? -eq 0; then \
pushd $(LIB_PATH) ;\
phpunit $(PHPUNIT_ARGS) ;\
popd ;\
elif test -r phpunit.phar; then \
pushd $(LIB_PATH) ;\
php $(top_srcdir)/phpunit.phar $(PHPUNIT_ARGS) ;\
popd ;\
else \
echo "Cannot find phpunit :("; \
echo "Aborting."; \
exit 1; \
testall: composer test testunit
@for group in generic standalone; do \
find $(top_srcdir)/tests/$$group -type f -name "*.diff" -o -name "*.exp" -o -name "*.log" -o -name "*.mem" -o -name "*.out" -o -name "*.php" -o -name "*.sh" | xargs rm -f; \
pecl package package.xml
php bin/prep-release.php $(MONGODB_VERSION) $(MONGODB_STABILITY)
# pecl/mongodb (MongoDB driver for PHP)
[![Build Status](](
[![Coverage Status](](
This is the low-level PHP driver for MongoDB. The API is the same
as the HHVM driver for MongoDB. The documentation for both of them is the same,
and can be found at
The driver is written to be a bare bone layer to talk to MongoDB, and
therefore misses many convenience features. Instead, these convenience methods
have been split out into a layer written in PHP, the
[MongoDB Library](
Using this library should be your preferred way of interacting with MongoDB.
Please note that the new HHVM and PHP drivers implement a **different API**
from the legacy driver at; therefore
existing libraries that use the legacy driver (e.g.
[Doctrine MongoDB's ODM](
will not work with the new drivers.
In the long run, we hope that userland packages will be built atop this driver
to implement various APIs (e.g. a BC layer for the existing driver, new fluent
interfaces), management utilities (for creating admin utilities and cluster
management applications), and other interesting libraries.
## Documentation
## Installation
To build and install the driver:
$ pecl install mongodb
$ echo "" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
We recommend using this extension in conjunction with our
[userland library](,
which is distributed as
[mongodb/mongodb]( for Composer.
## Contributing
See [](
## Related Projects
- [HHVM Implementation of this driver](
- [Official high-level library](
- [MongoDB Transistor]( Lightweight ODM using the [Persistable](\\persistable) interface
This diff is collapsed.
// vim:ft=javascript
function mongodb_generate_header(inpath, outpath, replacements)
STDOUT.WriteLine("Generating " + outpath);
var infile = FSO.OpenTextFile(inpath, 1);
var outdata = infile.ReadAll();
for (var key in replacements) {
var replacement = replacements[key];
if (typeof replacement === 'string') {
replacement = replacement.replace(/"/g, '\\"');
outdata = outdata.replace("@" + key + "@", replacement);
var outfile = FSO.CreateTextFile(outpath, true);
function mongodb_parse_version_file(inpath, prefix)
var infile = FSO.OpenTextFile(inpath, 1);
var version = infile.ReadLine();
var xyz_pre = version.split("-");
var xyz = xyz_pre[0].split(".");
var replacements = {};
replacements[prefix + "VERSION"] = version;
replacements[prefix + "MAJOR_VERSION"] = xyz[0];
replacements[prefix + "MINOR_VERSION"] = xyz[1];
replacements[prefix + "MICRO_VERSION"] = xyz[2];
replacements[prefix + "PRERELEASE_VERSION"] = xyz_pre[1];
return replacements;