Symfony4 - 从控制器访问sevices.yaml

I am starting a symfony4 project, and I learned the "parameters.yaml" is now "sevice.yaml".

I setted some variables inside like:

parameters:
    smugmug.oauth_token: 'XXX'
    smugmug.oauth_token_secret: 'XXX'

And i try to access it from my controller like:

    dump($this->container->get('smugmug.oauth_token'));

But I have an error...

How does this new way of storing global variables is working?

I think you have forgotten to extend the Controller class

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class ArticleController extends Controller
{
    public function controlAction()
    {
        // ...
        dump($this->container->getParameter('smugmug.oauth_token'));
        // Or this solution
        dump($this->getParameter('smugmug.oauth_token'));
        // ...
        // return a response
    }
}

Now, as Controller is deprecated and you have to use AbstractController, you need also a dependency injection for the service parameter:

namespace App\Controller;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class SetController extends  AbstractController  {

    private $params;

    public function __construct(ParameterBagInterface $params)
    {
        $this->params = $params;
    }
}

Then you can get your parameters like this:

$this->params->get( "app.your_stuff" );