你能帮我拿一下这个吗?
无法自动布线服务"App\Estimate\DocumentManager":方法"__construct()“的参数"$flysystem”引用类“__construct\Flysystem\Filesystem”,但不存在此类服务。您可能应该将这个类作为现有"oneup_flysystem.estimateDocumentsFilesystem_filesystem“服务的别名。
我的配置文件:
parameters:
flysystem.local.estimate_documents.path: '%kernel.root_dir%/../public/uploads/estimate/documents'
services:
app.estimate.document_manager:
class: App\Estimate\DocumentManager
lazy: true
public: true
arguments: ['@doctrine.orm.entity_manager', '@estimateDocumentsFilesystem', '@monolog.logger']
oneup_flysystem:
filesystems:
estimateDocumentsFilesystem:
adapter: estimateDocumentsAdapter
visibility: public
alias: "estimate_documents_filesystem"
adapters:
estimateDocumentsAdapter:
local:
directory: "%flysystem.local.estimate_documents.path%"
class DocumentManager
{
/**
* @var EntityManager
*/
private $manager;
/**
* @var Filesystem
*/
private $flysystem;
/**
* @var Logger
*/
private $logger;
/**
* DocumentManager constructor.
*
* @param EntityManagerInterface $manager
* @param Filesystem $flysystem
* @param Logger $logger
*/
public function __construct(
EntityManagerInterface $manager,
Filesystem $flysystem,
Logger $logger
)
{
$this->manager = $manager;
$this->flysystem = $flysystem;
$this->logger = $logger;
}
}非常感谢。我不明白问题出在哪里。
//编辑:
如果我添加thisIf,我会在配置中添加以下内容
services:
League\Flysystem\FilesystemInterface: '@estimate_documents_filesystem'它只适用于一个文件系统。是错的吗?
向吉米致以最良好的问候
发布于 2019-04-25 18:25:06
在我看来,禁用自动配置的答案是一个愚蠢的答案,因为Symfony的最佳实践是使用它。
问题是当前版本的OneupFlysystemBundle没有正确地配置它的服务来正确地使用Symfoyny的自动装配。
因此,在捆绑包内修复此问题之前,正确的解决方法是手动标记接口到正确的服务。在你的services.yaml中
League\Flysystem\FilesystemInterface: "@estimate_documents_filesystem"(注意:如果您使用此包的默认配置并遵循其步骤,则服务将被命名为"@oneup_flysystem.acme_filesystem",或者如果您只有一个文件系统,则遵循Symfony最佳实践,它应该是"@oneup_flysystem.app_filesystem"。如果不确定,可以使用bin/console debug:container查找服务的正确名称)
发布于 2020-04-07 10:05:10
要拥有多个文件系统,请执行以下操作:
services.yaml
services:
_defaults:
bind:
publicUploadFileSystem: '@oneup_flysystem.public_uploads_filesystem_filesystem'
oneup_flysystem.yaml
oneup_flysystem:
adapters:
public_uploads_adapter:
local:
directory: '%kernel.project_dir%/public/uploads'
filesystems:
public_uploads_filesystem:
adapter: public_uploads_adapter教程:https://symfonycasts.com/screencast/symfony-uploads/flysystem-usage#play
发布于 2018-07-30 18:42:23
需要关闭自动装配和自动配置。添加以下内容:
autoconfigure:false
autowire:false完整配置:
App\Estimate\Document\DocumentManager:
autoconfigure: false
autowire: false
arguments: ['@doctrine.orm.entity_manager', '@estimate_documents_filesystem', '@monolog.logger']
App\User\DocumentManager:
autoconfigure: false
autowire: false
arguments: ['@doctrine.orm.entity_manager', '@user_avatars_filesystem', '@monolog.logger']https://stackoverflow.com/questions/50665658
复制相似问题