Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]Automatic Service Loading
Lirdoner
post
Post #1





Grupa: Zarejestrowani
Postów: 500
Pomógł: 1
Dołączył: 29.09.2009

Ostrzeżenie: (0%)
-----


Cześć, mam problem z automatycznym ładowaniem serwisu. Zgodnie z dokumentacją: http://symfony.com/doc/current/service_container.html wystarczy, że utworzę klasę i nie muszę jej już nigdzie konfigurować. No więc zrobiłem klasę:
  1. <?php
  2.  
  3. namespace AppBundle\Model;
  4.  
  5. use Doctrine\ORM\EntityManagerInterface;
  6.  
  7. class CurrencyManager
  8. {
  9. const NBP_API_URL = 'http://api.nbp.pl/api/exchangerates/rates/{table}/{code}/';
  10.  
  11. private $em;
  12.  
  13. public function __construct(EntityManagerInterface $em)
  14. {
  15. $this->em = $em;
  16. }
  17. }

Jednak robią w kontrolerze
  1. $this->get(CurrencyManager::class)

Dostaję błąd
Kod
You have requested a non-existent service "AppBundle\Model\CurrencyManager".

services.yml:
Kod
parameters:
    #parameter_name: value

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false

    AppBundle\:
        resource: '../../src/AppBundle/*'
        exclude: '../../src/AppBundle/{Entity,Repository,Tests}'

    AppBundle\Controller\:
        resource: '../../src/AppBundle/Controller'
        public: true
        tags: ['controller.service_arguments']


Ten post edytował Lirdoner 21.07.2017, 14:02:58
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 11:06