答案 0 :(得分:3)
将以下配置添加到app/config/parameters.yml.dist
:
cloudant_hostname: ~
cloudant_port: 443
cloudant_use_ssl: true
cloudant_database: ~
cloudant_username: ~
cloudant_password: ~
~
”。安装sag:
> composer.phar require "sag/sag":"dev-master"
在捆绑包的services.yml
文件中定义服务:
services:
cloudant:
class: Sag
arguments:
- "%cloudant_hostname%"
- "%cloudant_port%"
calls:
- [useSSL, ["%cloudant_use_ssl%"]]
- [setDatabase, ["%cloudant_database%"]]
- [login, ["%cloudant_username%", "%cloudant_password%"]]
访问控制器中的服务:
/** @var \Sag $sag */
$sag = $this->get('cloudant');
/* You're now good to go! */
$post = $sag->get('postID')->body;