https://github.com/effectra/http-foundation
Effectra Http-Foundation is a package that provides foundation classes for handling HTTP requests and responses.
https://github.com/effectra/http-foundation
factory foundation http http-fou php psr psr7 request response stream uploadf uri
Last synced: 3 months ago
JSON representation
Effectra Http-Foundation is a package that provides foundation classes for handling HTTP requests and responses.
- Host: GitHub
- URL: https://github.com/effectra/http-foundation
- Owner: effectra
- Created: 2023-05-25T14:25:02.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T11:14:16.000Z (over 2 years ago)
- Last Synced: 2024-12-29T16:34:03.621Z (over 1 year ago)
- Topics: factory, foundation, http, http-fou, php, psr, psr7, request, response, stream, uploadf, uri
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Effectra\Http\Foundation
Effectra\Http\Foundation is a package that provides foundation classes for handling HTTP requests and responses.
## Installation
You can install this package via Composer. Run the following command in your terminal:
```bash
composer require effectra/http-foundation
```
## Classes
The package includes the following classes:
### RequestFoundation
The `RequestFoundation` class provides a foundation for creating PSR-7 compliant server request objects from PHP's global variables.
#### Usage
```php
use Effectra\Http\Foundation\RequestFoundation;
use Effectra\Contracts\Http\RequestFoundationInterface;
// Create a server request object from globals
$request = RequestFoundation::createFromGlobals();
// Access request attributes, query parameters, etc.
$path = $request->getUri()->getPath();
$queryParams = $request->getQueryParams();
// ... Add your code to handle the request ...
```
### ResponseFoundation
The `ResponseFoundation` class provides a foundation for sending PSR-7 compliant response objects.
#### Usage
```php
use Effectra\Http\Foundation\ResponseFoundation;
use Effectra\Contracts\Http\ResponseFoundationInterface;
// Create a response object
$response = new ResponseFoundation($content, $statusCode, $headers);
// Send the response
ResponseFoundation::send($response);
```
### UploadedFileFoundation
The `UploadedFileFoundation` class provides a foundation for representing uploaded files in HTTP requests.
#### Usage
```php
use Effectra\Http\Foundation\UploadedFileFoundation;
use Effectra\Contracts\Http\UploadedFileFoundationInterface;
// Create an uploaded file object
$uploadedFile = new UploadedFileFoundation($stream, $size, $error, $clientFilename, $clientMediaType);
// Access uploaded file properties
$stream = $uploadedFile->getStream();
$size = $uploadedFile->getSize();
$error = $uploadedFile->getError();
$clientFilename = $uploadedFile->getClientFilename();
$clientMediaType = $uploadedFile->getClientMediaType();
// ... Add your code to handle the uploaded file ...
```
## Contributing
Contributions are welcome! If you have any bug reports, feature requests, or suggestions, please open an issue on the [GitHub repository](https://github.com/effectra/http-foundation).
## License
This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).