K
K
kaxa32012019-10-04 15:38:26
symfony
kaxa3201, 2019-10-04 15:38:26

How to properly use Di container component symfony?

For some reason, Di container does not work, did I implement it correctly?
bootstrap.php

$container = new ContainerBuilder();
$loader = new DiYamlFileLoader($container, new FileLocator(__DIR__));
$loader->load('../config/services.yaml');
$container->compile();

services.yaml
services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false
  App\:
    resource: ../app/
    exclude: ../app/[a-z]*

  dependent.service:
    class: 'App\Interfaces\Services\ReportServiceInterface''
  demo.service:
    class: 'App\Generators\ReportGenerator'
    arguments: ['@dependent.service']

report generator
public function __construct(ReportServiceInterface $reportService)
    {
        $this->reportService = $reportService;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question