Manual
PHP Manual

php.ini Options

The behaviour of these functions is affected by settings in php.ini.

Mongo Configure Options
Name Default Changeable
mongo.native_long false* PHP_INI_ALL
mongo.long_as_object false PHP_INI_ALL
mongo.default_host "localhost" PHP_INI_ALL
mongo.default_port 27017 PHP_INI_ALL
mongo.auto_reconnect true PHP_INI_SYSTEM
mongo.allow_persistent true PHP_INI_SYSTEM
mongo.chunk_size 262144 PHP_INI_SYSTEM
mongo.cmd "$" PHP_INI_ALL
mongo.utf8 "1" PHP_INI_ALL
For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set.

Here's a short explanation of the configuration directives.

mongo.native-long int

The default behavior for this will be changed to TRUE in 1.1.0, so make sure to set this variable to the value you want (probably TRUE) so that the driver's behavior doesn't suddenly change when you upgrade.

On 64-bit platforms, the mongo.native_long setting allows for 64-bit integers to be stored in MongoDB. If it is not set, only 32-bits of the integer will be saved. The MongoDB data type that is used in this case is the BSON LONG, instead of the BSON INT that is used if this setting is turned off.

The setting also changes the way how BSON LONGs behave when they are read back from MongoDB. Without mongo.native_long enabled, the driver would convert every BSON LONG to a PHP double which can result in a loss of precision.

On 32-bit platforms, the mongo.native_log setting changes nothing for storing integers in MongoDB: the integer is stored as a BSON INT as before. However, when the setting is enabled and a BSON LONG is read from MongoDB a MongoCursorException is thrown alerting you that the data could not be read back without losing precision.

On 32-bit systems especially, it is recommended that you combine this with enabling mongo.long_as_object.

mongo.long_as_object string

Return a BSON_LONG as an instance of MongoInt64 (instead of a primitive type).

mongo.default_host string

Default hostname when nothing is passed to the constructor.

mongo.default_port string

The default TCP port number to use when connecting to the database server if no other port is specified. The database's default is 27017.

mongo.auto_reconnect bool

Whether to reconnect to the database if the connection is lost.

mongo.allow_persistent bool

If persistent connections are allowed.

mongo.chunk_size int

The number of bytes-per-chunk. Used in divvying up GridFS files. This number must be at least 100 less than 4 megabytes (max: 4194204) and it is recommended that it be less than that.

mongo.cmd string

A character to be used in place of $ in modifiers and comparisons.

mongo.utf8 int

If an exception should be thrown for non-UTF8 strings. Until version 1.0.4, the PHP driver would ignore non-UTF8 strings, even though you're not supposed to insert them. As of 1.0.4, the driver throws a MongoException. To ease the transition for applications that insert non-UTF8 strings, you can turn this option off to emulate the old, non-exception-throwning behavior. This option will be eliminated and exceptions always thrown for non-UTF8 strings starting with version 1.1.0.


Manual
PHP Manual