Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

returning Html in a controller symfony2

Tags:

php

symfony

I'm using Symfony2 and i need to use Curl to return Html from a Webservice, i tried to simply return $html , but Symfony2 fired :

Uncaught PHP Exception InvalidArgumentException: "Unable to find template ""

any help will be appreciated . Thank you

like image 350
Ayoub Idelhoussain Avatar asked Dec 22 '16 09:12

Ayoub Idelhoussain


2 Answers

Try:

class Controller
{
    public function foo()
    {
        return new Response(
            '<html><body>Hello</body></html>'
        );
    }
}
like image 125
Muhammad Faizan Uddin Avatar answered Sep 28 '22 17:09

Muhammad Faizan Uddin


A controller in Symfony must always return a Response object.

like image 43
Johnny Avatar answered Sep 28 '22 16:09

Johnny