pompdelux / kraken-bundle
将 Kraken.io 集成到您的 Symfony2 应用程序中
1.0.0
2014-05-19 09:07 UTC
Requires
- php: >=5.3.3
- misd/guzzle-bundle: 1.x
This package is not auto-updated.
Last update: 2024-09-14 16:24:04 UTC
README
此扩展包允许您将 kraken.io 集成到您的 Symfony2 应用程序中。
安装
-
将 KrakenBundle 添加到您的依赖项中
// composer.json { // ... "require": { // ... "pompdelux/kraken-bundle": "1.x" } }
-
使用 Composer 下载并安装扩展包
$ php composer.phar update pompdelux/kraken-bundle
-
在您的应用程序中注册扩展包
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ... new Pompdelux\KrakenBundle\KrakenBundle() ); } }
-
添加使用扩展包所需的配置
// config.yml kraken: services: service_name: api_key: your-kraken.io-key api_secret: your-kraken.io-secret
使用方法
基本示例
$kraken = $this->container->get('pompdelux.kraken.service_name'); $result = $kraken->squeeze('http://example.com/some/public/image.jpg');
使用回调而不是等待策略的示例
# config.yml kraken: services: ... callback_service: api_key: your-kraken.io-key api_secret: your-kraken.io-secret callback: true callback_route: your_callback_route # routing.yml acme_kraken_callback: pattern: /my/kraken/callback defaults: { _controller: AcmeTestBundle:Kraken:callback } requirements: _method: POST
$kraken = $this->container->get('pompdelux.kraken.callback_service'); $result = $kraken->squeeze('http://example.com/some/public/image.jpg'); // In AcmeTestBundle/Controller/KrakenController.php // // this method will be called once kraken.io is done processing your image. public function callbackAction(Request $request) { error_log(print_r($request->getContent(), 1)); return new Response(); }