I have a class that doesn't have access to the service container (because it does not extends the Controler class).
How can I get access to the parameters from parameters.ini in that class?
There are two ways I can think of:
Define your class as a service and inject the parameters into it. This is the cleanest solution.
Ex:
// parameters.ini
my_param: fooBar
// services.yml
tests.example:
class: some\class
arguments: [%my_param%]
fooBar will now be passed to your class constructor.
Define your class as a service and inject the container service into it. This is not recommended and I'm only listing it because it's technically possible.
$this->get('tests.example'); in the controller) and must not create it manually. Take a look at the official documentation at symfony.com/doc/current/book/service_container.html