您尝试实例化PHP类VolumeInfo,但此PHP类不存在!
一个办法 :
控制器:
$items = $content->items;
return $this->render(‘BooksBookBundleInfo.html.twig’, array (‘items’=>$items));
</code>
模板:
{% for item in items %}
Title : {{ item.volumeInfo.title }}
Author :
{% for author in item.volumeInfo.authors %}
{{ item.volumeInfo.authors[0] }}
{% endfor %}
{% endfor %}
</code>
或者,如果您总是有一本书,则可以直接将书籍传递给模板:
控制器:
$items = $content->items[0];
return $this->render(‘BooksBookBundle
Info.html.twig’, array (‘item’=>$item));
</code>