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条回答 默认 最新

相关推荐 更多相似问题