We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Switching from View\Simple to View causes errors

I set up all my projects as micro application using View\Simple. As I need a dispatcher now, I made some modification to my bootstrap class and using Phalcon\Mvc\Application, but kept simple view. On first page reload after making modifications I get:

Call to undefined method ::start()

thrown by $application->handle(). It took my half an hour to realize it is caused by View\Simple. So I replaced it with default view. After that, next error occurs:

Wrong number of parameters

thrown by $this->di->view->render('backend/users'); This took my another half an hour. When changing line to ->render('backend', 'users'); (i.e. separating folder from Volt file) the page gets rendered. That's annoying, as I'm using many partials and often the Volt file is generated dynamically as string in a variable. The only way for me to prevent changing all render()calls, was to extend Views\Simpleand add missing methods start()and finish(). Is there another way to get default View working without changing my controllers?

are you using the view service from the DI containter?


I'm accessing it directly with $this->view->render(), but yes, this is a service inside DI.

You can have both a View and ViewSimple service in your DI. The View will be used by default, but you can still use ViewSimple if you're wanting to render dynamic strings.