Answer the question
In order to leave comments, you need to log in
Symfony2: How to add a class from the vendor folder to the service container?
Actually a subject. I downloaded a third party library from GitHub. Uploaded to the vendor folder. Connected in autoload a new namespace. I want to call in the controller like this:
so far it only works like this:$foo = $this->get('bar');
use \bar;
$bar = new Bar();
services:
foo:
class: \Bar
Answer the question
In order to leave comments, you need to log in
For a container, it doesn't matter where the file is physically located. That's up to the autoloader. If you have registered the service in services.yml:
services:
fooService:
class: \Bar
$foo = $this->get('fooService');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question