utopia-php/mongo
Composer 安装命令:
composer require utopia-php/mongo
包简介
A simple library to manage Mongo database
README 文档
README
A non-blocking PHP client based on the line protocol for MongoDB. Designed to work well in async PHP environments like Swoole This library is aiming to be as simple and easy to learn and use. This library is maintained by the Appwrite team.
Getting Started
Install using composer:
composer require utopia-php/mongo
Init in your application:
<?php $client = new Client('testing', 'mongo', 27017, 'root', 'example', false); $client->connect(); // drop database $client->dropDatabase([]); // Create a new collection $client->createCollection('movies'); // Get the list of databases $client->listDatabaseNames()->databases; // insert a new document $document = $client->insert('movies', [ 'name' => 'Armageddon 1', 'country' => 'USA', 'language' => 'English' ] ); $id = (string)$document['_id']; // Find Document with ObjectId $client->find('movies', ['_id' => new ObjectId($id)])->cursor->firstBatch ?? []; // insert a new document with specific id $id = 999; $client->insert('movies', [ 'name' => 'Armageddon 2', '_id' => $id, 'array' => ['USA', 'UK', 'India'], 'language' => 'English', 'float' => 9.9, 'integer' => 9, 'is_open' => true, 'date_string' => (new \DateTime())->format('Y-m-d\TH:i:s.vP'), ] ); // Find document by id $client->find('movies', ['_id' => $id])->cursor->firstBatch ?? []; // Find documents by field $client->find('movies', ['name' => 'Armageddon'])->cursor->firstBatch ?? []; // Delete a document $client->delete('movies', ['_id' => $id]); // drop a collections $client->dropCollection('movies');
System Requirements
Utopia Mongo client requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.
Copyright and license
The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php
utopia-php/mongo 适用场景与选型建议
utopia-php/mongo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 359.28k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2022 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「php」 「mongo」 「upf」 「utopia」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 utopia-php/mongo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 utopia-php/mongo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 utopia-php/mongo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
MongoDB extension for the Yii framework
PHP module for MySql database
统计信息
- 总下载量: 359.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 25
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-10