Fetching contributors…
Cannot retrieve contributors at this time
308 lines (215 sloc) 9 KB

Contributing to the PHP Driver for MongoDB

Building from Source

Developers who would like to contribute to the driver will need to build it from source. The repository may be initialized with:

$ git clone
$ cd mongo-php-driver
$ git submodule update --init

The following script may be used to build the driver:


phpize > /dev/null && \
./configure --enable-developer-flags > /dev/null && \
make clean > /dev/null && make all > /dev/null && make install


The test suite expects to find PHONGO-SERVERS.json in the system temp directory (e.g. /tmp). This file should contain a JSON object with MongoDB URIs and resemble the following:

    "STANDALONE": "mongodb:\/\/",
    "STANDALONE_24": "mongodb:\/\/",
    "STANDALONE_26": "mongodb:\/\/",
    "STANDALONE_30": "mongodb:\/\/",
    "STANDALONE_SSL": "mongodb:\/\/",
    "STANDALONE_AUTH": "mongodb:\/\/root:toor@\/?authSource=admin",
    "STANDALONE_X509": "mongodb:\/\/C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,CN=client@\/?authSource=$external&authMechanism=MONGODB-X509",
    "STANDALONE_PLAIN": "mongodb:\/\/root:toor@\/?authSource=admin",
    "REPLICASET": "mongodb:\/\/,,\/?replicaSet=REPLICASET",
    "REPLICASET_30": "mongodb:\/\/,,\/?replicaSet=REPLICASET_30"

The location of this PHONGO-SERVERS.json file can be configured by exporting a PHONGO_SERVERS environment variable with the absolute path to the JSON configuration file.

Our test suite also includes scripts to configure the necessary test environment with Vagrant and Mongo Orchestration. This is the preferred way of creating PHONGO-SERVERS.json and running the test suite:

$ make vm             # Starts the test VMs with Vagrant
$ make test-bootstrap # Starts the mongod servers within the test VM

The test-bootstrap make target also generates the required PHONGO-SERVERS.json file. The test make target may be used to execute the test suite:

$ make test # Executes the test suite against the VMs

Mongo Orchestration

Some tests interact directly with Mongo Orchestration to start their own servers for cluster testing (e.g. replica set failovers). These tests depend on MONGODB_ORCHESTRATION_HOST and MONGODB_ORCHESTRATION_PORT environment variables.

By default, these tests will use the Mongo Orchestration instance within the test VM.

Restarting Mongo Orchestration

If something goes awry in the test VM, it may be helpful to start the VM and Mongo Orchestration with the following script:


rm -f /tmp/PHONGO-SERVERS.json
vagrant reload mo
vagrant ssh mo -c 'sudo rm /home/vagrant/'
vagrant ssh mo -c 'sudo mongo-orchestration -f mongo-orchestration-config.json -b --enable-majority-read-concern start'
make test-bootstrap


The follow steps outline the release process for a maintenance branch (e.g. releasing the vX.Y branch as X.Y.Z).

Ensure PHP version compatibility

Ensure that the extension compiles on PHP 5.4, 5.5, 5.6, and 7.0. Be sure to test both ZTS and non-ZTS builds for PHP 5.x.

Ensure Windows compatibility

PECL will create Windows DLLs for new releases; however, you must ensure that the extension successfully builds on Windows before releasing. Note that PHP 5.5 and 5.6 require VS2012, while PHP 7 requires VS2015.

Given the following assumptions:

  • Build directory is C:\php-sdk\
  • Compiling for PHP 5.6 (VS2012 x86 Native Tools Command Prompt is running)
  • Extension branch checked out in C:\php-sdk\phpdev\vc11\x86\pecl\mongodb

The build process will resemble:

cd c:\php-sdk\

cd C:\php-sdk\phpdev\vc11\x86\php-5.6.12-src
nmake clean
buildconf --force
configure --disable-all --with-openssl --enable-cli --enable-json --enable-mongodb

If the extension was successfully compiled, "mongodb" should be reported by Release_TS\php.exe -m.

See the internals wiki for more information.

Transition JIRA issues and version

Update the fix version field for all resolved issues with the corresponding ".x" fix version.

Update the version's release date and status from the Manage Versions page.

Transition all resolved issues for this version to the closed state. If changing the issues in bulk, be sure to allow email notifications.

Update version info

The PHP driver uses semantic versioning. Do not break backwards compatibility in a non-major release or your users will kill you.

Before proceeding, ensure that the master branch is up-to-date with all code changes in this maintenance branch. This is important because we will later merge the ensuing release commits up to master with --strategy=ours, which will ignore changes from the merged commits.

Update the version and stability constants in php_phongo.h. This should entail removing the version's "-dev" suffix and changing the stability to "stable":

#define MONGODB_VERSION_S "1.1.8-dev"
#define MONGODB_STABILITY_S "devel"

The above would be changed to:

#define MONGODB_VERSION_S "1.1.8"
#define MONGODB_STABILITY_S "stable"

The Makefile targets for creating the PECL package depend on these constants, so you must rebuild the extension after updating php_phongo.h.

Publish PECL package

Create the PECL package description file with make package.xml. This creates a package.xml file from a template. Version, author, and file information will be filled in, but release notes must be copied manually from JIRA.

After copying release notes, use make package to create the package file (e.g. mongodb-X.Y.Z.tgz) and ensure that it can be successfully installed:

$ pecl install -f mongodb-X.Y.Z.tgz

The PECL package may be published via the Release Upload form. You will have one chance to confirm the package information after uploading.

Commit version update and release notes

Commit the modified php_phongo.h file as "Package X.Y.Z"

$ git add php_phongo.h
$ git commit -m "Package X.Y.Z"

Tag release

The previous commit will be the target for our release tag:

$ git tag -a -m "Release X.Y.Z" X.Y.Z

Update version info back to dev

After tagging, the version and stability constants in php_phongo.h should be updated back to development status.

#define MONGODB_VERSION_S "1.1.8"
#define MONGODB_STABILITY_S "stable"

The above would be changed to:

#define MONGODB_VERSION_S "1.1.9-dev"
#define MONGODB_STABILITY_S "devel"

Commit this change:

$ git commit -m "Back to -dev" php_phongo.h

Push commits and tags

$ git push
$ git push --tags

Merge the maintenance branch up to master

$ git checkout master
$ git merge vX.Y --strategy=ours
$ git push

The --strategy=ours option ensures that all changes from the merged commits will be ignored.

Publish release notes

The following template should be used for creating GitHub release notes via this form. The PECL package may also be attached to the release notes.

The PHP team is happy to announce that version X.Y.Z of our new [mongodb]( PHP extension is now available on PECL.

**Release Highlights**

<one or more paragraphs describing important changes in this release>

A complete list of resolved issues in this release may be found at:


Documentation is available on


We would appreciate any feedback you might have on the project:


You can either download and install the source manually, or you can install the extension with:

    pecl install mongodb

or update with:

    pecl upgrade mongodb

Windows binaries are available on PECL:

The URL for the list of resolved JIRA issues will need to be updated with each release. You may obtain the list from this form.

If commits from community contributors were included in this release, append the following section:


Thanks for our community contributors for X.Y.Z:


Release announcements should also be sent to the and mailing lists.

Consider announcing each release on Twitter. Significant releases should also be announced via @MongoDB as well.