douji3623 2015-01-13 10:53
浏览 51
已采纳

在Symfony2中使用带有KnpGaufrette和Doctrine的VichUploader时的循环引用

I tried to use the following setup in my Symfony2 project:

Problem: As soon as i try to use the Gaufrette storage adapter "doctrine_dbal" I get the following error:

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]                                                                                                                                                                                                                 
Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.orm.default_entity_manager -> doctrine.dbal.default_connection -> vich_uploader.upload_handler -> vich_uploader.storage.gaufrette -> knp_gaufrette.filesystem_map -> gaufrette.storage_fs_filesystem".  

The problem occurs as soon as Symfony tries to check the configuration, e.g. on

app/console cache:clear

How can I resolve this issue?

My Setup

My project setup is the default setup of symfony/framework-standard-edition with version 2.5.* without AcmeDemo Bundle.

I simply did add the Bundles via Composer:

composer require knplabs/knp-gaufrette-bundle vich/uploader-bundle

... added them to AppKernel's registerBundles():

//...
$bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),
        new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new AppBundle\AppBundle(),
        new Vich\UploaderBundle\VichUploaderBundle(), //NEW 
        new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(), //NEW
    );
//...

... and added the following configuration to config.yml, which is based on the docs VichUploader with Gaufrette and KnpGaufrette with Doctrine DBAL:

# ...
knp_gaufrette:
    stream_wrapper: ~

    adapters:
        storage_adapter:
            doctrine_dbal:
                connection_name: default
                table: data_storage
                columns:
                    key: id
                    content: file
                    mtime: mtime
                    checksum: checksum

    filesystems:
        storage_fs:
            adapter:    storage_adapter



vich_uploader:
    db_driver: orm
    storage:   gaufrette

    mappings:
        storage:
            uri_prefix:         /images/products
            upload_destination: storage_fs
  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失