Giancarlo Ventura Granados Giancarlo Ventura Granados - 11 months ago 47
PHP Question

Use paramater value in a custom class (Symfony2)

I have some parameter values in app/config/parameters.yml

database_port: null
database_name: database_name
igv: 0.18
isc: 0.18

Now, I want to use the parameters in a Custom class in AppBundle/CustomClass.php. How can I use this parameters? I try $this->container->get('igv') but not works.

Answer Source

In services.yml:

    class:  AppBundle\CustomClass
    arguments: ['%igv%', '%isc%']

Add the arguments to the constructor of AppBundle\CustomClass.