use Symfony\Component\HttpFoundation\Response; $response = new Response(); $response->headers->set('Content-Type', 'text/plain'); $response->setContent('Hello, World!'); $response->setStatusCode(Response::HTTP_OK); $response->send();
use Illuminate\Http\Response; $response = new Response(view('home')); $response->header('X-Content-Type-Options', 'nosniff')->cookie('name', 'value'); return $response;In this example, we use the Response class from the Laravel package library to create a new HTTP response object. We set the content of the response to a view named "home" and add an X-Content-Type-Options header to the response. Additionally, we set a cookie named "name" with the value "value". Finally, we return the response to the client. Overall, the package library used for the Response class will depend on the specific PHP framework being used for the web application. Popular package libraries for creating HTTP responses include Symfony, Laravel, and Slim.