abellion / xenus-laravel
Xenus 对 Laravel 和 Lumen 框架的集成
0.4
2022-07-04 19:39 UTC
Requires
- php: ^7.1.3 || ^8.0
- abellion/xenus: ^0.18.0 || ^0.19.0
- illuminate/contracts: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/database: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/queue: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/support: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
Requires (Dev)
- illuminate/config: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/container: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/events: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^7.5 || ^8.0 || ^9.0 || ^9.0
README
此包将 Xenus 集成到 Laravel 和 Lumen 框架(从版本 5.8
到最新版本 9.0
)
- 开箱即用的 失败任务 和 迁移 集成
- 准备就绪的 事件调度器
Xenus 是一个简单优雅的 MongoDB ODM。了解更多: https://github.com/abellion/xenus
安装
如果您尚未安装 Xenus,并且满足其对 mongodb
扩展的要求,在需要此包之前,请确保安装扩展: https://php.ac.cn/manual/en/mongodb.installation.php 安装完成后,需要包含此包。
composer require abellion/xenus-laravel
配置
Xenus\Connection
类的实例将自动构建并注册到服务容器中。为此,Xenus 会从您的 config/database.php
文件中的 mongodb.connection
键读取连接设置。它至少需要包含您要连接的 host
和 database
。
[ 'mongodb' => [ 'connection' => [ 'host' => 'mongodb://:27017', 'database' => 'my_database' ] ] ]
服务提供者
为了配置您的集合,即将其链接到 Laravel 的事件调度器并在服务容器中定义为单例,您必须创建一个服务提供者。此服务提供者必须扩展 Xenus\Laravel\XenusServiceProvider
并包含一个 $collections
属性,其中包含您的集合。
use Xenus\Laravel\XenusServiceProvider as ServiceProvider; class XenusServiceProvider extends ServiceProvider { protected $collections = [ MyCollection::class ]; }
失败的任务和迁移
失败的任务和迁移桥接器已经预配置并准备好使用。如果您想更改它们使用的默认集合名称,请编辑以下内容:
对于迁移
// config/database.php [ 'migrations' => 'my_migration_collection' ]
对于失败的任务
// config/queue.php [ 'failed' => [ 'collection' => 'my_failed_jobs_collection' ] ]
许可证
Xenus 采用 MIT 许可证。