alcaeus/mongo-php-adapter
Compatibility layer that lets legacy PHP MongoDB drivers (ext-mongo) work with the newer mongodb extension and library. Helps modernize apps with minimal code changes by translating old APIs to the current MongoDB PHP driver.
alcaeus/mongo-php-adapter (v1.2.5) remains a transitional tool for Laravel applications (pre-5.4+) relying on the deprecated ext-mongo PHP extension. The new release introduces PHP 8.2 compatibility and fixes a regression caused by private API usage, addressing critical stability concerns for modern PHP environments.jenssegers/laravel-mongodb) is preferred, this adapter now aligns better with Laravel 9/10’s PHP 8.2 requirements, reducing friction for teams stuck with legacy MongoDB logic.ext-mongo calls with adapter wrappers.mongodb/mongodb: Adapter targets older versions (1.0–1.15). Verify no breaking changes in newer releases (e.g., 1.16+) affect the adapter.jenssegers/laravel-mongodb: Still incompatible; avoid mixing.mongodb/mongodb or jenssegers/laravel-mongodb.create_function).mongodb/mongodb.ext-mongo quirks (e.g., cursors, write concerns) may still differ. Test:
jenssegers/laravel-mongodb?mongodb/mongodb directly? Assess the effort to rewrite legacy logic.| Component | Compatible Versions | Notes |
|---|---|---|
| PHP | 7.2–8.2 | PHP 8.2 now supported; test thoroughly. |
| Laravel | 5.4–10.x | PHP 8.2 enables Laravel 9/10 support. |
mongodb/mongodb |
1.0–1.15 | No change; ensure no breaking updates in newer versions. |
jenssegers/... |
Avoid mixing | Conflicts remain; choose one approach. |
ext-mongo usage and PHP 8.2 deprecations (e.g., create_function).composer require alcaeus/mongo-php-adapter:^1.2.5
// config/database.php
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'client' => \Alcaeus\MongoDb\MongoClient::class,
'host' => env('DB_HOST'),
'options' => [
'phpVersion' => '8.2.0', // Explicitly set for clarity
],
],
]
mongodb/mongodb directly.jenssegers/laravel-mongodb.MongoClient initializes correctly with PHP 8.2’s stricter typing.ext-mongo or adapter code using deprecated PHP 8.2 features.int vs. string in queries).MongoException for valid queries.mongodb/mongodb directly, reducing adapter dependency.jenssegers/laravel-mongodb.composer.json to pin alcaeus/mongo-php-adapter:^1.2.5 to avoid unintended upgrades.mongodb/mongodb 1.16+ if upgrading.insertMany).How can I help you explore Laravel packages today?