Кто-нибудь сталкивался с ошибкой ниже и знает, в чем может быть проблема? Я использую пакет исключений для вывода сообщений об исключениях на основе JSON для REST API.
C:\htdocs\projects\myproject>php bin/console cache:clear --no-warmup
PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: The definition
for "ApiExceptionBundle\Component\Factory\ResponseFactoryInterface" has no class attribute, and appears to
reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed
for namespaced classes. Please specify the class attribute explicitly to get rid of this error. in C:\htdoc
s\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckDefinitio
nValidityPass.php:52
Stack trace:
#0 C:\htdocs\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\Com
piler.php(143): Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass->process(Object(
Symfony\Component\DependencyInjection\ContainerBuilder))
#1 C:\htdocs\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBui
lder.php(731): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\ in C:\htdoc
s\projects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckDefinitio
nValidityPass.php on line 52
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: The definition for
"ApiExceptionBundle\Component\Factory\ResponseFactoryInterface" has no class attribute, and appears to refe
rence a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for n
amespaced classes. Please specify the class attribute explicitly to get rid of this error. in C:\htdocs\pro
jects\myproject\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckDefinitionVali
dityPass.php on line 52
Symfony\Component\DependencyInjection\Exception\RuntimeException: The definition for "ApiExceptionBundle\Co
mponent\Factory\ResponseFactoryInterface" has no class attribute, and appears to reference a class or inter
face in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Ple
ase specify the class attribute explicitly to get rid of this error. in C:\htdocs\projects\myproject\vendor\s
ymfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass.php on line 5
2
Call Stack:
4.6333 13914032 1. Symfony\Component\Debug\ErrorHandler->handleException() C:\htdocs\projects\alire
st\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php:0
C:\htdocs\projects\myproject>
Вот файл, на который он ссылается:
<?php
namespace ApiExceptionBundle\Component\Factory;
use ApiExceptionBundle\Component\Api\ApiProblemInterface;
interface ResponseFactoryInterface
{
public function createResponse(ApiProblemInterface $apiProblem);
}
Все есть здесь, в документе
тип подсказка (ApiExceptionBundle\Component\Api\ApiProblemInterface
) не совпадает с идентификатором сервиса (ApiExceptionBundle\Component\Api\ApiProblem
?). Это означает, что аргумент не может быть автоматически подключен.
Вы должны добавить псевдоним
services:
ApiExceptionBundle\Component\Api\ApiProblemInterface: '@ApiExceptionBundle\Component\Api\ApiProblem'
Других решений пока нет …