use Symfony\Component\HttpFoundation\Response; $template = 'Hello, %name%!'; $data = ['name' => 'John']; $response = Response::createFromTemplate($template, $data); $response->send();
use Symfony\Component\HttpFoundation\Response; $template = 'This example creates a more complex HTML page with a dynamic title and content section. The `$data` array is used to replace the `%title%` and `%content%` variables in the template. The resulting response object is then sent to the browser. In both examples, the Response class is used to create the response object. This class is part of the Symfony HttpFoundation library, which provides a set of classes for creating HTTP responses and handling HTTP requests.%title% %content%'; $data = ['title' => 'My Website', 'content' => 'Welcome to my website
This is the home page.
']; $response = Response::createFromTemplate($template, $data); $response->send();