cimrie/slick
Composer 安装命令:
composer require cimrie/slick
包简介
Fluent ODM Metadata Builder for cimrie/odm, the FW Integration package for Doctrine MongoDB ODM.
README 文档
README
Doctrine ODM Fluent Metadata Class Implementation. Inspired by laravel-doctrine/fluent. Integrates seamlessly with cimrie/odm.
Laravel Setup
Add CImrie\Slick\SlickServiceProvider::class to the 'providers' section of config/app.php.
Follow the instructions for cimrie/odm.
In config/odm.php set 'meta' to CImrie\Slick\Mapping\SlickDriver::class
For each manager in config/odm.php specify a 'mappings' array like so:
<?php return [ 'managers' => [ 'default' => [ // ... 'meta' => env('DOCTRINE_METADATA', \CImrie\Slick\Mapping\SlickDriver::class), 'mappings' => [ MyCustomMappingClass::class ] // ... ] ] ];
Usage
To set up your mapping files, you should extend one of the following classes:
- Normal Documents:
CImrie\Slick\Mapping\DocumentMapping::class, - Embedded Documents:
CImrie\Slick\Mapping\EmbeddedMapping::class, - Mapped Superclass Documents:
CImrie\Slick\Mapping\MappedSuperclassMapping::class
In each of the mapping files you will need to specify a mapFor and a map(Slick $builder) method implementaton.
mapFor should simply return the class name of the document you wish to map.
map(...) should make use of the $builder variable given in order to specify its mapping.
For example:
<?php use \Tests\Model\Documents\User; use CImrie\Slick\Slick; class CustomMapping extends \CImrie\Slick\Mapping\DocumentMapping { public static function mapFor(){ return User::class; } public function map(Slick $builder) { $builder->id(); $builder->string('name'); $builder->string('email')->unique(); // alternatively add the unique constraint manually //... $builder->index()->key('email')->unique(); $builder->date('joinedAt'); } }
统计信息
- 总下载量: 38
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-29