1 に答える
3
- Cloudant を構成します (DB、API キーなどを作成します)。
次の構成を に追加します
app/config/parameters.yml.dist
。cloudant_hostname: ~ cloudant_port: 443 cloudant_use_ssl: true cloudant_database: ~ cloudant_username: ~ cloudant_password: ~
- 必要に応じて、" " の代わりにデフォルト値を指定できます
~
。
- 必要に応じて、" " の代わりにデフォルト値を指定できます
サグをインストールします。
> composer.phar require "sag/sag":"dev-master"
- このステップの最後に、Composer は上記のパラメーターの値を入力するように求めます。
バンドルの
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;
于 2013-12-06T19:03:44.473 に答える