我想加载服务。
return $this->get(ApiServerService::class)->response([/**/]);
我的服务在目录中: 供应商/ DidUngar / ApiServerBundle /服务 文件名是: ApiServerService
标题是:
<?php
namespace DidUngar\ApiServerBundle\Services;
use Symfony\Component\HttpFoundation\Request;
use DidUngar\ApiServerBundle\Entity\Logs;
use DidUngar\ApiServerBundle\Exception\PublicException;
class ApiServerService
{
/**/
}
要获得良好的负载,我正在使用composer(为此我将其捆绑在供应商中),composer.json为:
{
"name": "DidUngar/ApiServerBundle",
"type": "library",
"description": "Helper for build a API Server.",
"authors": [
{
"name": "Didier Ungar",
"email": "didungar@gmail.com"
}
],
"autoload": {
"psr-4": {"DidUngar\\ApiServerBundle\\": ""}
},
"require": {
"php": ">=7.0.0"
}
}
这是我的错误:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
0) You have requested a non-existent service "DidUngar\ApiServerBundle\Services\ApiServerService".
#0 /www/vendor/symfony/dependency-injection/Container.php(222): Symfony\Component\DependencyInjection\Container->make('DidUngar\\ApiSer...', 1)
#1 /www/vendor/symfony/framework-bundle/Controller/ControllerTrait.php(61): Symfony\Component\DependencyInjection\Container->get('DidUngar\\ApiSer...')
#2 /www/src/Controller/MapController.php(20): Symfony\Bundle\FrameworkBundle\Controller\Controller->get('DidUngar\\ApiSer...')
#3 /www/vendor/symfony/http-kernel/HttpKernel.php(149): App\Controller\MapController->indexAction(Object(Symfony\Component\HttpFoundation\Request))
#4 /www/vendor/symfony/http-kernel/HttpKernel.php(66): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#5 /www/vendor/symfony/http-kernel/Kernel.php(188): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#6 /www/public/index.php(37): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#7 {main}
您可以读取我的路径/ www,这是我的docker工作的结果。 (我认为没有影响)
我确定我的命名空间配置丢失。 但是当我检查自动装货时,他缝得很好。
'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib/Doctrine/Common'),
'Doctrine\\Bundle\\MigrationsBundle\\' => array($vendorDir . '/doctrine/doctrine-migrations-bundle'),
'Doctrine\\Bundle\\DoctrineCacheBundle\\' => array($vendorDir . '/doctrine/doctrine-cache-bundle'),
'Doctrine\\Bundle\\DoctrineBundle\\' => array($vendorDir . '/doctrine/doctrine-bundle'),
'DidUngar\\ApiServerBundle\\' => array($vendorDir . '/DidUngar/ApiServerBundle'),
'App\\Tests\\' => array($baseDir . '/tests'),
'App\\' => array($baseDir . '/src'),
);
你有个主意吗?