Download the PHP package zealphp/mongodb without Composer

On this page you can find all versions of the php package zealphp/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

zealphp-mongodb

Tests Coding Standards Static Analysis Coverage

Async MongoDB driver for PHP — a Rust extension bridging the official mongo-rust-driver into PHP via ext-php-rs, with non-blocking coroutine support through OpenSwoole.

Drop-in replacement for mongodb/mongodb with the same Collection, Database, Client, and BSON APIs.

Performance

C driver parity achieved. 7 of 10 operations match or beat the official C driver (ext-mongodb). Total overhead: +4.1%.

200 iterations, median timing, PHP 8.4.5, MongoDB 6.0, same host:

Operation zealphp-mongodb ext-mongodb (C) Gap
findOne 0.442ms 0.451ms -1.9%
find(50) 0.550ms 0.494ms +11.3%
find(1000) 4.270ms 3.764ms +13.4%
insertOne 0.297ms 0.292ms +1.6%
updateOne 0.493ms 0.519ms -5.0%
deleteOne 0.598ms 0.610ms -2.1%
countDocuments 0.883ms 0.901ms -2.1%
aggregate 1.415ms 1.458ms -2.9%
distinct 0.795ms 0.820ms -3.0%
findOneAndUpdate 0.511ms 0.539ms -5.1%

With coroutine parallelism (ZealPHP/OpenSwoole), 4 parallel queries complete in 0.69ms vs 1.7ms sequential on the C driver — 3.4x faster. Under HTTP concurrency (ab -n 500 -c 20), throughput is 3.9x–6.7x higher than Apache + C driver:

Endpoint Apache (C driver) ZealPHP (Rust driver) Speedup
Landing page (5 DB queries) 120 req/s · 78ms p50 465 req/s · 20ms p50 3.9x
/features (lightweight) 254 req/s · 37ms p50 1699 req/s · 5ms p50 6.7x

Measured in production on the same container, same MongoDB, same dataset (10k+ users). The landing page parallelizes 5 count queries via Channel(5) + go() coroutines; Apache runs them sequentially.

See docs/case-study-dual-runtime.md for the full analysis.

Features

Requirements

Installation

Build the Rust extension

Docker

The extension builds automatically in Docker — see the labs-devops Dockerfile for reference:

Install the PHP library

Quick Start

Async Mode (OpenSwoole)

When running inside an OpenSwoole coroutine, all MongoDB operations automatically become non-blocking:

API Reference

Collection Methods

Method Description
findOne($filter, $options) Find a single document
find($filter, $options) Find documents (returns Cursor)
insertOne($document) Insert a single document
insertMany($documents) Insert multiple documents
updateOne($filter, $update, $options) Update a single document
updateMany($filter, $update, $options) Update multiple documents
deleteOne($filter) Delete a single document
deleteMany($filter) Delete multiple documents
replaceOne($filter, $replacement, $options) Replace a single document
countDocuments($filter) Count documents matching filter
estimatedDocumentCount() Fast approximate count
distinct($field, $filter) Get distinct values
aggregate($pipeline) Run aggregation pipeline
findOneAndUpdate($filter, $update, $options) Find and update atomically
findOneAndDelete($filter) Find and delete atomically
findOneAndReplace($filter, $replacement, $options) Find and replace atomically
bulkWrite($operations) Execute bulk operations
createIndex($keys, $options) Create an index
createIndexes($indexes) Create multiple indexes
listIndexes() List collection indexes
dropIndex($name) Drop an index
dropIndexes() Drop all indexes
drop() Drop the collection
rename($newName) Rename the collection
count($filter) Alias for countDocuments

Database Methods

Method Description
command($command) Run a database command
aggregate($pipeline) Database-level aggregation
createCollection($name) Create a collection
dropCollection($name) Drop a collection
drop() Drop the database
listCollections() List collections
listCollectionNames() List collection names
selectCollection($name) Get a Collection instance
selectGridFSBucket() Get a GridFS Bucket (stub)

BSON Types

Type Extended JSON
ObjectId {"$oid": "..."}
UTCDateTime {"$date": {"$numberLong": "..."}}
Regex {"$regularExpression": {"pattern": "...", "options": "..."}}
Binary {"$binary": {"base64": "...", "subType": "..."}}
Decimal128 {"$numberDecimal": "..."}
Int64 Native int
Timestamp {"$timestamp": {"t": ..., "i": ...}}
Javascript {"$code": "..."}
MinKey {"$minKey": 1}
MaxKey {"$maxKey": 1}

Architecture

Development

License

MIT


All versions of mongodb with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
mongodb/mongodb Version ^1.15 || ^2.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 zealphp/mongodb contains the following files

Loading the files please wait ...