https://github.com/labrador-kennel/http-cors
Middleware for @amphp http-server to handle CORS requests!
https://github.com/labrador-kennel/http-cors
amphp cors http-server
Last synced: about 1 month ago
JSON representation
Middleware for @amphp http-server to handle CORS requests!
- Host: GitHub
- URL: https://github.com/labrador-kennel/http-cors
- Owner: labrador-kennel
- License: mit
- Created: 2019-02-09T06:40:19.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-05-04T23:17:40.000Z (almost 2 years ago)
- Last Synced: 2025-10-05T07:32:33.715Z (6 months ago)
- Topics: amphp, cors, http-server
- Language: PHP
- Homepage: https://labrador-kennel.io/docs/http-cors
- Size: 60.5 KB
- Stars: 10
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-amphp - labrador-kennel/http-cors - Middleware for amphp/http-server to handle CORS requests (HTTP / Server)
README
# Labrador HTTP CORS
[](https://github.com/labrador-kennel/http-cors/releases/latest)
[](http://opensource.org/licenses/MIT)
A PHP 8+ library intended to provide spec-compliant CORS middleware for projects running on [Amp's http-server](https://amphp.org/http-server/).
Though this library lives under the Labrador namespace it has only one dependency, `amphp/http-server`, and does not depend
on any other Labrador packages.
## Installation
[Composer](https://getcomposer.org) is the only supported method for installing Labrador packages.
```
composer require cspray/labrador-http-cors
```
## Example
Below is an example using the fluent API. Please check out the documentation for more details and examples of non-fluent
usage.
```php
allowMethods('GET', 'POST', 'PUT', 'DELETE')
->withMaxAge(8600)
->allowRequestHeaders('X-Request-Header')
->exposeResponseHeaders('X-Response-Header')
->doAllowCredentials()
->build();
$loader = new SimpleConfigurationLoader($configuration);
$middleware = new CorsMiddleware($loader);
```
## Supported Versions
Only the 1.x release series is officially supported at this time. The previous 0.x release series will not see new
features and will only see critical security fixes.
## Documentation
Labrador packages have thorough documentation in-repo in the `docs/` directory. You can also check out the documentation
online at [https://labrador-kennel.io/docs/http-cors](https://labrador-kennel.io/docs/http-cors).
## Governance
All Labrador packages adhere to the rules laid out in the [Labrador Governance repo](https://github.com/labrador-kennel/governance).