Migrating 4 to 5: replacing Zend's headLink and headScript?


Up until Pimcore 4 the Zend Framework was used. In a lot of controllers I have pieces of code like this to include stylesheets and scripts. What is the recommended way of doing this in Pimcore 5?



this should work as before … Pimcore 5 ships with several templating helpers: https://pimcore.com/docs/5.0.x/MVC/Template/Templating_Helpers/index.html



Hi Fash,

Thanks for the reply, but they are not working for me. Is there anything I need to configure/enable/register?

All my calls to the view helpers in any controller throw an exception similar to this:

HTTP 500 Internal Server Error
Attempted to call an undefined method named "headLink" of class "Pimcore\Templating\Model\ViewModel".

My code in /src/AppBundle/Controller/DefaultController.php:

namespace AppBundle\Controller;

class DefaultController extends \Pimcore\Controller\FrontendController {

    public function init() {

    public function homeAction() {


Ah, you can’t do that in the controller anymore that way. Either you move that to the view, or you get the service from the container ($this->get('Pimcore\Templating\Helper\HeadLink')) and then call appendStylesheet on it.


Thank you very much, it is working a lot better this way!


namespace AppBundle\Controller;

class DefaultController extends \Pimcore\Controller\FrontendController {
    public function homeAction() {

        $headLink = $this->get('Pimcore\Templating\Helper\HeadLink');

        $headScript = $this->get('Pimcore\Templating\Helper\HeadScript');


if you register your controllers as services and use autowiring, you also could add the template helpers as params to your action - this would free your code from direct container access.
public function homeAction(Pimcore\Templating\Helper\HeadLink $headLink, Pimcore\Templating\Helper\HeadScript $headScript) {...}