{"id":14966451,"url":"https://github.com/yiisoft/db-mongodb","last_synced_at":"2025-10-19T09:31:20.105Z","repository":{"uuid":"143317025","full_name":"yiisoft/db-mongodb","owner":"yiisoft","description":"Yii Framework MongoDB extension","archived":false,"fork":false,"pushed_at":"2023-01-16T22:23:18.000Z","size":10619,"stargazers_count":12,"open_issues_count":5,"forks_count":5,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-03-21T14:17:42.660Z","etag":null,"topics":["hacktoberfest","mongodb","optionalforframeworkannounce","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2018-08-02T16:02:37.000Z","updated_at":"2023-11-27T04:57:39.000Z","dependencies_parsed_at":"2023-02-10T06:45:14.079Z","dependency_job_id":null,"html_url":"https://github.com/yiisoft/db-mongodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fdb-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fdb-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fdb-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fdb-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/db-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":192435247,"owners_count":12699560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","mongodb","optionalforframeworkannounce","yii3"],"created_at":"2024-09-24T13:36:24.313Z","updated_at":"2025-10-19T09:31:19.816Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.mongodb.com/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://webassets.mongodb.com/_com_assets/cms/mongodb-logo-rgb-j6w271g1xn.jpg\" height=\"100px\" alt=\"MongoDB\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Database MongoDB driver\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/db-mongodb/v/stable.png)](https://packagist.org/packages/yiisoft/db-mongodb)\n[![Total Downloads](https://poser.pugx.org/yiisoft/db-mongodb/downloads.png)](https://packagist.org/packages/yiisoft/db-mongodb)\n[![Build status](https://github.com/yiisoft/db-mongodb/workflows/build/badge.svg)](https://github.com/yiisoft/db-mongodb/actions?query=workflow%3Abuild)\n[![Code Coverage](https://codecov.io/gh/yiisoft/db-mongodb/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/db-mongodb)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-mongodb%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-mongodb/master)\n[![static analysis](https://github.com/yiisoft/db-mongodb/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/db-mongodb/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/db-mongodb/coverage.svg)](https://shepherd.dev/github/yiisoft/db-mongodb)\n[![psalm-level](https://shepherd.dev/github/yiisoft/db-mongodb/level.svg)](https://shepherd.dev/github/yiisoft/db-mongodb)\n\nThis extension provides the [MongoDB](https://www.mongodb.com/) integration for the [Yii framework](https://www.yiiframework.com).\n\n## Requirements\n\n- [MongoDB PHP Extension](https://www.php.net/manual/en/set.mongodb.php) version 1.8.0 or higher.\n- MongoDB server version 3.0 or higher.\n- PHP 8.1 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/db-mongodb\n```\n\n## General usage\n\nTo use this extension, simply add the following code in your application configuration:\n\n```php\nreturn [\n    //....\n    'components' =\u003e [\n        'mongodb' =\u003e [\n            'class' =\u003e Yiisoft\\Db\\MongoDb\\Connection::class,\n            'dsn' =\u003e 'mongodb://@localhost:27017/mydatabase',\n            'options' =\u003e [\n                \"username\" =\u003e \"Username\",\n                \"password\" =\u003e \"Password\"\n            ]\n        ],\n    ],\n];\n```\n\nOnce you have a MongoDB connection instance, you can execute a MongoDB commands and queries\nusing `Yiisoft\\Db\\MongoDb\\Command`:\n\n```php\n// execute command:\n$result = Yii::$app-\u003emongodb-\u003ecreateCommand(['listIndexes' =\u003e 'some_collection'])-\u003eexecute();\n\n// execute query (find):\n$cursor = Yii::$app-\u003emongodb-\u003ecreateCommand(['projection' =\u003e ['name' =\u003e true]])-\u003equery('some_collection');\n\n// execute batch (bulk) operations:\nYii::$app-\u003emongodb-\u003ecreateCommand()\n    -\u003eaddInsert(['name' =\u003e 'new'])\n    -\u003eaddUpdate(['name' =\u003e 'existing'], ['name' =\u003e 'updated'])\n    -\u003eaddDelete(['name' =\u003e 'old'])\n    -\u003eexecuteBatch('customer');\n```\n\nUsing the connection instance you may access databases and collections.\nMost of the MongoDB commands are accessible via `\\Yiisoft\\Db\\MongoDb\\Collection` instance:\n\n```php\n$collection = Yii::$app-\u003emongodb-\u003egetCollection('customer');\n$collection-\u003einsert(['name' =\u003e 'John Smith', 'status' =\u003e 1]);\n```\n\nTo perform `find` queries, you should use `\\Yiisoft\\Db\\MongoDb\\Query`:\n\n```php\nuse Yiisoft\\Db\\MongoDb\\Query;\n\n$query = new Query();\n// compose the query\n$query-\u003eselect(['name', 'status'])\n    -\u003efrom('customer')\n    -\u003elimit(10);\n// execute the query\n$rows = $query-\u003eall();\n```\n\n## Documentation\n\n- Guide: [English](docs/guide/en/README.md), [Français](docs/guide/fr/README.md), [Русский](docs/guide/ru/README.md), [日本語](docs/guide/ja/README.md)\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Database MongoDB driver is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fdb-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fdb-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fdb-mongodb/lists"}