Symfony 4.2.3
最近从 3.4 版本升级到 4.2.3 并让我的项目工作,但是在 services.yaml 中将 autoconfigure 设置为 true 时,我会收到此错误消息:
Cannot autowire service "App\EventListener\RedirectToLocaleActiveListener": argument "$localeActive" of method "__construct()" has no type-hint, you should configure its value explicitly.
Run Code Online (Sandbox Code Playgroud)
我的服务.yaml
parameters:
locale: de
locale_active: de
app_locales: de|en
uploads_directory_name: uploads
uploads_profile_directory_name: profiles
uploads_directory: '%kernel.root_dir%/../public/%uploads_directory_name%'
profile_directory: '%kernel.root_dir%/../public/%uploads_directory_name%/%uploads_profile_directory_name%'
google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%'
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: ../src/Controller
tags:
- controller.service_arguments
locales:
class: App\Util\Locales
arguments:
- '%locale_active%'
- '%app_locales%'
- '@session'
app.locale:
class: App\EventListener\LocaleListener
tags: …
Run Code Online (Sandbox Code Playgroud) 我想让FOSElasticaBundle工作.ElasticSearch Instance正在localhost:9200上运行并响应.
我按照文档中的每一步https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md
但在最后一步,我在我的控制台中收到此错误:
c:\xampp\htdocs\my\folder>php app/console fos:elastica:populate
Resetting app
Fatal error: Wrong parameters for Exception([string $exception [, long $code [,
Exception $previous = NULL]]]) in C:\xampp\htdocs\my\folder\vendor\rufli
n\elastica\lib\Elastica\Exception\ResponseException.php on line 34
[Symfony\Component\Debug\Exception\FatalErrorException]
Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])
fos:elastica:populate [--index[="..."]] [--type[="..."]] [--no-reset] [--offset="..."] [--sleep="..."] [--batch-size="..."] [--ignore-errors] [--no-overwrite-format]
Run Code Online (Sandbox Code Playgroud)
看起来"__construct"-Function必须有3个参数,但只有2个参数.我只是尝试添加"NULL"参数以使其工作,但随后另一个函数抛出错误.
public function __construct(Request $request, Response $response)
{
$this->_request = $request;
$this->_response = $response;
parent::__construct($response->getError());
}
Run Code Online (Sandbox Code Playgroud)
这是个常见的问题吗?我该如何解决?