as3 / modlr-bundle
Modlr REST ODM 库的 Symfony 扩展包。
dev-master
2016-10-19 15:53 UTC
Requires
- php: >=5.4
- as3/modlr: >=0.3.4 <1.0
- symfony/framework-bundle: >=2.0 <2.7 || ^3.0
- symfony/yaml: >=2.0 <2.7 || ^3.0
This package is not auto-updated.
Last update: 2024-09-14 19:14:42 UTC
README
将 modlr REST 库与 Symfony 集成。
安装
要使用 modlr,您必须安装一个持久化和 API 规范。
要使用 modlr 中的搜索功能,您必须安装一个搜索客户端。
可用的模块可以在这里找到,或者您可以自己编写!
使用 Composer 安装包
要安装此扩展包并支持 MongoDB、elasticsearch 和 JSON Api Spec,请将以下内容添加到您的 composer.json 文件中
{
"require": {
"as3/modlr-bundle": "dev-master",
"as3/modlr-api-jsonapiorg": "dev-master",
"as3/modlr-search-elastic": "dev-master",
"as3/modlr-persister-mongodb": "dev-master"
}
}
然后,告诉 Composer 更新并安装请求的包
composer update as3/modlr-bundle --with-dependencies
注册扩展包
安装完成后,请在您的 AppKernel.php
中注册扩展包
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new As3\Bundle\ModlrBundle\As3ModlrBundle(),
);
// ...
}
配置
Modlr 需要一些配置才能工作。您可以使用以下默认配置开始
# app/config/config.yml
as3_modlr:
rest:
root_endpoint: /api
debug: "%kernel.debug%"
adapter:
type: jsonapiorg
persisters:
default:
type: mongodb
parameters:
host: mongodb://:27017
search_clients:
default:
type: elastic
要使用外部 REST API,您还必须包含 modlr 的路由文件。这将允许 modlr 处理所有对 as3_modlr.rest.root_endpoint
的请求。为了防止任何路由冲突,您应该在添加任何其他扩展包或应用程序路由定义之前添加此文件。
# app/config/routing.yml
as3_modlr_bundle:
resource: "@As3ModlrBundle/Resources/config/routing.yml"
接下来,您必须定义您的模型!默认情况下,modlr 的元数据驱动程序将在 app/Resources/As3ModlrBundle/models
和 app/Resources/As3ModlrBundle/mixins
中查找 YAML 文件。
您可以通过设置元数据驱动程序的 models_dir
参数来自定义定义的存储位置。有关更多信息,请参阅扩展包配置文档。
使用方法
有关更多信息,请参阅modlr 文档。
此扩展包提供用于重建 modlr 的元数据缓存的命令
app/console as3:modlr:metadata:cache:clear [model_type] [--no-warm]
创建集合模式
app/console as3:modlr:schema:create [model_type]