开发者

How to use Zend GData in a Symfony2 project

I'm working on a project based on Symfony2 framework, and I would like to be able to search for Youtube videos and display them. For that, I've been trying to figure out a way to load Zend GData classes into my Symfony2 controller, but there's very little or no documentation about this topic. So I would like to know if there's a way o开发者_运维知识库f doing this.

Thanks in advance.


  1. add this line to the namespaces array of your autoload.php file:

    'Zend' => DIR.'/../vendor/Zend/library',

  2. use the classes just as you would do in a zend app:

    $gdata = new \Zend\GData\GData();

It might be useful to register and use some classes as services, but that's another topic...


  1. Create the following directory structure in your vendor/ dir:

    • vendor/
    • -> zend/
    • --> lib/
    • ---> Zend/
    • ----> [Zend directory from Zend GData package]
    • --> README
    • --> LICENSE
  2. Register 'Zend_' prefix in your app/autoload.php:

    $loader->registerPrefixes(array(
    // ... Some previous prefixes like Twig and Twig_Extensions
    'Zend_' => DIR.'/../vendor/zend/lib',
    ));

  3. According to Fabien's presentation about symfony 1.4 and ZF integration you also need to dynamically change your include_path. Add the following code at the bottom of your app/autoload.php:

    // Zend Framework GData needs a special autoload fix too set_include_path(DIR.'/../vendor/zend/lib'.PATH_SEPARATOR.get_include_path());

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜