Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Mongo Php Adapter

Mongo Php Adapter Laravel Package

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.

View on GitHub
Deep Wiki
Context7

:link: [Deprecated] Adapter to provide ext-mongo interface on top of mongo-php-library

Frequently asked questions about Mongo Php Adapter
Can I use alcaeus/mongo-php-adapter in Laravel 9+ to replace ext-mongo?
Yes, but with caution. The adapter targets older MongoDB PHP drivers and may conflict with Laravel 9+'s stricter dependencies. Test thoroughly, as newer Laravel versions favor direct mongodb/mongodb integration via packages like jenssegers/laravel-mongodb.
How do I install this adapter in a Laravel project?
Run `composer require alcaeus/mongo-php-adapter`. Then configure your Laravel service provider to resolve MongoDB connections through the adapter’s `MongoClient` wrapper instead of the deprecated extension. Replace direct `ext-mongo` calls with the adapter’s methods.
Will this adapter work with jenssegers/laravel-mongodb?
No, avoid mixing them. The adapter replaces ext-mongo functionality, while jenssegers/laravel-mongodb is built for mongodb/mongodb. Choose one approach to prevent conflicts or unexpected behavior in your Laravel application.
Does this adapter support all ext-mongo features?
Most core features are supported, but edge cases like cursors, write concerns, or legacy query syntax may behave differently. Test critical paths (e.g., bulk operations, aggregations) to ensure compatibility with your Laravel app’s MongoDB logic.
Is this package safe for production use in Laravel?
It’s a viable short-term solution, but the package is deprecated. Monitor performance and query behavior closely. Plan to migrate to mongodb/mongodb or jenssegers/laravel-mongodb before Laravel or PHP updates break compatibility.
How do I handle PHP 8.2 compatibility with this adapter?
The adapter supports PHP 7.2–8.2, but ensure your Laravel app’s other dependencies (e.g., mongodb/mongodb) also align. Test thoroughly, as PHP 8.2’s stricter typing may expose issues in legacy ext-mongo code paths.
What’s the performance impact of using this adapter?
The abstraction layer may introduce slight overhead, especially for complex queries. Benchmark critical operations (e.g., bulk writes) against native mongodb/mongodb. Optimize queries or consider direct migration if performance is critical.
Can I use this adapter with MongoDB 5.0+ servers?
Yes, the underlying `mongodb/mongodb` library supports MongoDB 3.6+. However, test server-specific features (e.g., transactions, new aggregation stages) as the adapter may not expose all modern capabilities.
What’s the best way to test this adapter in Laravel?
Write unit tests for legacy ext-mongo queries using the adapter’s wrappers. Mock MongoDB responses to verify behavior matches your app’s expectations. Focus on edge cases like cursors, timeouts, and schema validation differences.
Should I migrate directly to mongodb/mongodb or use this adapter first?
Use the adapter only for incremental migration if your Laravel app has extensive ext-mongo dependencies. For smaller projects, consider skipping the adapter and adopting jenssegers/laravel-mongodb directly to avoid technical debt.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin