rdrenth/tvrage-bundle

此包已被放弃,不再维护。没有建议的替代包。

Symfony 包用于 adrenth/tvrage 包

安装: 14

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 0

开放问题: 0

类型:symfony-bundle

0.1.2 2015-08-31 19:17 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:50:43 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

关于

这是一个用于 adrenth/tvrage 包的 Symfony2 Bundle。更多信息请访问 https://github.com/adrenth/tvrage

安装

步骤 1:使用 Composer 安装 RdrenthTvrageBundle

$ composer require rdrenth/rvrage-bundle

步骤 2:启用该 Bundle

<?php

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
        // ...
        new Rdrenth\TvrageBundle\RdrenthTvrageBundle(),
        // ...
    );
}

步骤 3:配置您的 config.yml 文件(可选)

adrenth/tvrage 包需要 Doctrine Cache 实例。默认情况下,此 Bundle 使用 VoidCache 实例以便于设置。

有关如何配置 Doctrine Cache Bundle 的更多信息,请访问 https://github.com/doctrine/DoctrineCacheBundle

如果您想使用现有的 doctrine 缓存提供者,这可能适用

# app/config/config.yml
doctrine_cache:
    providers:
        array_cache:
            type: array
            
rdrenth_tvrage:
    cache: doctrine_cache.providers.array_cache

使用方法

配置 Bundle 后,您可以从 Symfony 的 Container 中获取客户端,例如在 Controller 中

<?php

// src/AppBundle/Controller/DefaultController.php

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller
{
    public function searchAction(Request $request)
    {
        $tvrageClient = $this->get('rdrenth_tvrage.client');
        $shows = array();
        
        try {
            $response = $tvrageClient->search($request->get('query', 'Breaking Bad'));
            $shows = $response->getShows();
        } catch (\Exception $e) {
        
        }
        
        return $this->render('default/search.html.twig', array('shows' => $shows));
    }
}

许可证

此 Bundle 在 MIT 许可证下。请参阅包中的完整许可证

Resources/meta/LICENSE