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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀