How do I read from parameters.yml in a controller in symfony2?

前端 未结 7 849
眼角桃花
眼角桃花 2020-12-07 13:49

I have put a couple of custom variables in my app/config/parameters.yml.

parameters:
    api_pass: apipass
    api_user: apiuser

I need to

7条回答
  •  一向
    一向 (楼主)
    2020-12-07 14:09

    You can use:

    public function indexAction()
    {
       dump( $this->getParameter('api_user'));
    }
    

    For more information I recommend you read the doc :

    http://symfony.com/doc/2.8/service_container/parameters.html

提交回复
热议问题