use Symfony\Component\HttpFoundation\Response; $response = new Response('Hello, world!'); $response->headers->set('Content-Type', 'text/plain'); $response->sendHeaders();
use Symfony\Component\HttpFoundation\Response; $response = new Response(); $response->headers->set('Content-Disposition', 'attachment; filename="example.txt"'); $response->headers->set('Content-Type', 'text/plain'); $response->setContent('This is an example file.'); $response->sendHeaders();This example creates a new Response object and sets the Content-Disposition and Content-Type headers. The setContent() method is used to add the content to the response. Finally, the sendHeaders() method is called to send the headers and content to the client. Overall, the Symfony Component HttpFoundation package library is a powerful tool for building PHP applications and handling HTTP requests and responses.