Get variable from controller in twig using template I have a php variable in my controller and i want to use it in twig.
So i do this : 

Controller : 

$firstLetter = '2017'; //dynamic variable but for the test it's a constant 

$build ['list'] = array(
      '#theme' =&gt; 'liste-adh2',
      '#content'=&gt;$result,
      '#filters'=&gt;$ListApport,
      '#filters2' =&gt;$Listline,
      '#test' =&gt; $firstLetter,  //sending to my template
   );  

return $build;


Template :

function adh_apport_theme($existing, $type, $theme, $path)
{

    return [
        'liste-adh2' =&gt; [
            'variables' =&gt; ['content' =&gt; NULL, 'filters' =&gt; NULL,
                            'filters2' =&gt; NULL,], ['test' =&gt; NULL,],
                        ],
            ];
}


Twig :

{{ test.firstLetter }}


i got nothing in twig and i don't know why.

Thanks for helping.
I’m not sure why you’re expecting test to be an object, you declared it as a string.

Assuming the value of “2017” from your example is what you’re trying to get the variable is just:

{{ test }}