Skip to content

Commit

Permalink
README, CHANGELOG for 1.0 release (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
cspray authored May 4, 2024
1 parent 46b68af commit fc2a67a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Changelog

## Unreleased
## 1.0 - 2024-05-04

### Changed

- Add support for amphp v3
- Add support for PHP 8.1 & 8.2
- Add support for PHP 8.1+

### Removed

Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![GitHub release](https://img.shields.io/github/release/labrador-kennel/http-cors.svg?style=flat-square)](https://github.com/labrador-kennel/http-cors/releases/latest)
[![GitHub license](https://img.shields.io/github/license/labrador-kennel/http-cors.svg?style=flat-square)](http://opensource.org/licenses/MIT)

A PHP 7+ library intended to provide spec-compliant CORS middleware for projects running on [Amp's http-server](https://amphp.org/http-server/).
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.

Expand All @@ -15,6 +15,34 @@ on any other 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
<?php

use Cspray\Labrador\Http\Cors\ConfigurationBuilder;
use Cspray\Labrador\Http\Cors\SimpleConfigurationLoader;
use Cspray\Labrador\Http\Cors\CorsMiddleware;

$configuration = ConfigurationBuilder::forOrigins('https://example.com', 'https://foo.example.com')
->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
Expand Down
2 changes: 1 addition & 1 deletion docs/how-tos/implement-own-configurationloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final class MultiTenantConfigurationLoader implements ConfigurationLoader {
#### 4. Handle no Configuration for Request

If you've added logic to have many types of Configurations it is likely you may encounter a Request that does not match
that logic and you cannot reliably determine a Configuration for. Based on your application's needs you will need to
that logic and you cannot reliably determine a Configuration for. Based on your application's needs you will have to
determine how to handle this scenario to fix the Null Pointer Error that can occur in code from step 3.

##### Option 1: Return a default Configuration instance
Expand Down

0 comments on commit fc2a67a

Please sign in to comment.