Passing an array of object from custom module to template in drupal 8
In your controller why you are using like this

'#myvariable' =&gt; array('key' =&gt; $myArrayofObjects),


Change it as

'#myvariable' =&gt; $myArrayofObjects,


and in my-page.html.twig

&lt;p&gt;Test twig template!&lt;/p&gt;    
&lt;p&gt;{{text}}&lt;/p&gt;

{% for key, value in myvariable %}
  Key : {{ key }}
  Name : {{ value.name }}
  User ID : {{ value.user_id }}
  Email : {{ value.email }}
{% endfor %}