Weave 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
Yii2 Mongodb

Yii2 Mongodb Laravel Package

yiisoft/yii2-mongodb

The official Yii2 MongoDB extension integrates MongoDB with the Yii framework, providing Connection, Query, Collection, and ActiveRecord components. It enables Yii2 applications to use MongoDB collections through familiar Yii APIs, including query building, data access, and model persistence.

Deep Wiki
Context7

Yii2 MongoDB is the official MongoDB extension for the Yii 2 framework, providing seamless integration between Yii’s database layer and MongoDB. It lets you use familiar Yii patterns—ActiveRecord, QueryBuilder, and Data Providers—while working with document-oriented data.

  • ActiveRecord support for MongoDB collections, relations, and embedded documents.
  • QueryBuilder and Command classes for fluent query construction.
  • Migrator and schema support for managing collections and indexes.
  • GridFS integration for storing and retrieving large files.
  • Works with Yii 2’s caching, validation, and data provider APIs.
Frequently asked questions about Yii2 Mongodb
Can I use yiisoft/yii2-mongodb in a Laravel application?
Not directly. yiisoft/yii2-mongodb is a Yii 2 framework extension whose components depend on Yii's application bootstrap, service locator, aliases, and base classes, so Laravel's container, Eloquent, and facades cannot consume it natively. Direct adoption is low-feasibility; you could only run it in an isolated Yii 2 service or behind an anti-corruption layer. For greenfield Laravel work, use mongodb/laravel-mongodb or the official MongoDB PHP library instead.
What is yiisoft/yii2-mongodb used for?
It is the official MongoDB extension for Yii 2 applications, providing connection, collection, query builder, ActiveRecord, GridFS, caching, and session components. It lets Yii apps store and query data in MongoDB using familiar Yii APIs, either alongside or instead of relational databases. Its value is tied to Yii 2 rather than framework-agnostic MongoDB access.
Is yiisoft/yii2-mongodb still maintained?
The last release was 2018-03-30, so the package is effectively stale. Security fixes and driver/API updates are unlikely, and compatibility with current PHP 8.x, modern ext-mongodb, and contemporary MongoDB features is uncertain. Budget for internal ownership, patches, and dependency pins if you must keep it.
What Laravel package should I use instead of yii2-mongodb?
For Laravel, use mongodb/laravel-mongodb, which integrates with Eloquent and Laravel's container and lifecycle. If you only need raw MongoDB access, wrap the official MongoDB PHP library in application repositories. These options are Laravel-native and avoid the operational overhead of running Yii 2 components.
Does yiisoft/yii2-mongodb support PHP 8 and modern MongoDB drivers?
Compatibility is unproven. The 2018 release predates current PHP 8.x and modern ext-mongodb API versions, and there is no evidence of upstream testing against contemporary stacks. Treat PHP 8 and modern driver support as a gating compatibility spike, not an assumption, before any commitment.
Does yiisoft/yii2-mongodb work with Laravel Eloquent?
No. Its ActiveRecord implementation is built on Yii 2 base classes and does not plug into Eloquent models, relationships, or Laravel's query builder. You would need a separate data-access layer or bridge, which adds dual-framework complexity. Laravel teams should use an Eloquent-compatible MongoDB adapter.
How do I install yiisoft/yii2-mongodb?
It is installed via Composer as yiisoft/yii2-mongodb and configured inside a Yii 2 application, typically by adding MongoDB connection and component definitions to the Yii config. It requires the ext-mongodb PHP extension and a compatible Yii 2 version. Installation in Laravel is not a supported path because the package expects Yii's bootstrap and service locator.
Can yiisoft/yii2-mongodb provide MongoDB caching and sessions in Laravel?
It includes Yii 2 cache and session components, but they are designed for Yii's component model and configuration, not Laravel's cache and session drivers. Laravel would not recognize them as native drivers, so you would need custom bridging and lifecycle handling. Use Laravel-native cache and session stores instead.
Is yiisoft/yii2-mongodb a security or production risk?
Technical risk is high because the package is stale and upstream security fixes are unlikely. Failure modes include Composer conflicts, PHP/runtime incompatibility, ext-mongodb API drift, Yii bootstrap or DI failures, and lack of modern MongoDB feature coverage. Do not make it a core dependency without an internal maintainer, fork strategy, and rollback plan.
How do I migrate from Yii 2 MongoDB ActiveRecord to Laravel?
Treat yiisoft/yii2-mongodb as technical debt or a bounded legacy adapter. Inventory Yii 2 MongoDB usage, put repository interfaces in front of it, optionally run the Yii component in an isolated service, then migrate read paths first and write paths second. Decommission only after contract and data-consistency tests pass.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource