fastpress / response
An efficient and flexible HTTP response handling library for PHP, designed to integrate seamlessly with the Fastpress framework. It offers easy-to-use methods for managing HTTP responses, headers, and status codes.
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-14 21:32:22 UTC
README
A part of the Fastpress framework, Fastpress\Http\Response is a PHP class designed for handling HTTP responses efficiently and effectively. It offers a comprehensive set of features for managing response codes, headers, body content, and more, making it an indispensable tool for any PHP web application.
Features
- Response Code Management: Easily set HTTP response codes and corresponding texts.
- Response Body Handling: Define and manage the body content of responses.
- Headers Management: Add and manipulate response headers.
- Redirection Support: Simple methods to redirect users to different URLs.
- Caching Controls: Methods to control and disable browser caching.
- Protocol Specification: Customize the HTTP protocol version.
- Content Rendering: Render the response content and headers efficiently.
- Page Refresh: Facilitate immediate page refreshes.
Installation
Use Composer to integrate Fastpress\Http\Response into your project:
composer require fastpress/response
Requirements
- PHP 7.4 or higher.
Usage
Setting Response Code and Text
use Fastpress\Http\Response; $response = new Response(); $response->setResponse(200, 'OK');
Setting Response Body
$response->setBody('Your response content here');
Adding Headers
$response->addHeader('Content-Type', 'application/json');
Redirecting
$response->redirect('https://your-redirect-url.com', 301);
Disabling Browser Cache
$response->disableBrowserCache();
Contributing
Contributions are welcome! Please feel free to submit a pull request or open issues to improve the library.
License
This library is open-sourced software licensed under the MIT license.
Support
If you encounter any issues or have questions, please file them in the issues section on GitHub.