Symfony 3.4, use parameters.yml in controller


I want to read a record of parameters.yml in a controller. I do not know why but with Swift Mailer it works for me, but not in any other way. This I am trying:

//Mi Controller
class ExampleController extends Controller
    function someMethod($argument)

Here I have in parameters.yml:

    free_proxy: "http://xxx:8080"

I get the error: Call to a member function getParameter() on null

I also tried like this:

        autowire: true
        autoconfigure: true
        public: false
          $freeProxy: '%free_proxy%'

And then with:


And I get: Unused binding "$freeProxy" in service...

How then can I use a simple log in the controller? Like I said, with Swift Mailer there's no problem when I use:

$message = \Swift_Message::newInstance()->setSubject($this->getParameter('mailer_subjet'))  etc...

I can read "mailer_subject" which is in parameters.yml, but why not the other one?

asked by pmirnd 02.01.2019 в 20:36

0 answers