Download the PHP package xp-forge/mongodb without Composer

On this page you can find all versions of the php package xp-forge/mongodb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mongodb

MongoDB connectivity

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

This library implements MongoDB connectivity via its binary protocol. It has no dependencies on the PHP extension.

Examples

Finding documents inside a collection:

Inserting a document into a collection:

Updating documents:

Upserting documents:

Deleting documents:

Note: All of the above have used the collection() shortcut which is equivalent to chaining database('test')->collection('products').

Authentication

To authenticate, pass username and password via the connection string, e.g. mongodb://user:pass@localhost. The authentication source defaults to admin but can be set by supplying a path, e.g. mongodb://user:pass@localhost/test.

Both SCRAM-SHA-256 and SCRAM-SHA-1 are supported as authentication mechanisms. Which one is used is negotiated upon connecting with the server / cluster. To explicitely select the authentication mechanism, pass it as part of the connection string, e.g. mongodb://user:pass@localhost?authMechanism=SCRAM-SHA-256.

SSL / TLS

To connect via SSL / TLS, pass ssl=true as connection string parameters, e.g.:

Aggregation

The Collection class also features aggregation methods:

See https://docs.mongodb.com/manual/reference/command/nav-aggregation/

Commands

To run commands on a given collection, use the run() method:

See https://www.mongodb.com/docs/manual/reference/command/ for a list of commands.

DNS Seed List Connection

Adding in DNS to specify clusters adds another level of flexibility to deployment. Given the following DNS entries:

...the following code will connect to one of the above:

Sessions

Using a causally consistent session, an application can read its own writes and is guaranteed monotonic reads, even when reading from replica set secondaries.

Handling errors

All operations raise instances of the com.mongodb.Error class. Connection and authentication errors can be handled by checking for CannotConnect:

Type mapping

All builtin types are mapped to their BSON equivalents. In addition, the following type mappings are used:

The deprecated types of the BSON spec are not supported, see http://bsonspec.org/spec.html


All versions of mongodb with dependencies

PHP Build Version
Package Version
Requires xp-framework/core Version ^12.0 | ^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0
xp-framework/networking Version ^10.0 | ^9.0 | ^8.0
xp-framework/math Version ^9.1
php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package xp-forge/mongodb contains the following files

Loading the files please wait ....