Использую отдельный компонент "symfony/http-foundation" пишу тестовые классы
Получаю вот такую ошибку
The routing file "/code/app/Http/Controllers/../../../config/services.yaml" contains unsupported keys for "services": "demo.service", "dependent.service". Expected one of: "resource", "type", "prefix", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition", "controller", "name_prefix", "trailing_slash_on_root", "locale", "format", "utf8".
services:
demo.service:
class: \App\Services\DemoService
dependent.service:
class: \App\Services\DependentService
arguments: ["@demo.service"]
<?php
namespace App\Services;
class DemoService
{
public function helloWorld()
{
return "Hello World!\n";
}
}
<?php
namespace App\Services;
class DependentService
{
private $demo_service;
public function __construct( $demoService)
{
$this->demo_service = $demoService;
}
public function helloWorld()
{
return $this->demo_service->helloWorld();
}
}
class ExampleController
{
public function test(Request $request)
{
$containerBuilder = new ContainerBuilder();
$loader = new YamlFileLoader(new FileLocator(__DIR__));
$loader->load('../../../config/services.yaml');
$service = $containerBuilder->get('dependent.service');
echo $serviceOne->helloWorld();
}
}