PivotPHP Core v1.0.1 is designed with PSR-7 v2.0 but allows installation with either PSR-7 v1.x or v2.x through composer constraints.
{
"require": {
"psr/http-message": "^1.1|^2.0"
}
}PivotPHP Core's HTTP message implementations (ServerRequest, Request, Response, Stream, etc.) are built following PSR-7 v2.0 specifications, which include:
- Return type declarations on interface methods
- Parameter type declarations
- Stricter type safety
While composer allows installation alongside PSR-7 v1.x, the actual PivotPHP Core classes require PSR-7 v2.0 interfaces at runtime. This means:
- Direct Usage: Projects using PivotPHP Core directly should use PSR-7 v2.0
- Mixed Environments: Projects that need to use both PivotPHP Core and libraries requiring PSR-7 v1.x (like ReactPHP) will need:
- A PSR-7 bridge/adapter layer
- Or separate PSR-7 implementations for different parts of the application
If you need to integrate PivotPHP Core with ReactPHP (which uses PSR-7 v1.x), consider:
// Use a PSR-7 bridge to convert between versions
use Acme\Psr7Bridge;
// ReactPHP PSR-7 v1.x request
$reactRequest = $event->getRequest();
// Convert to PSR-7 v2.0 for PivotPHP
$pivotRequest = Psr7Bridge::fromV1ToV2($reactRequest);
// Process with PivotPHP
$pivotResponse = $app->handle($pivotRequest);
// Convert back to PSR-7 v1.x for ReactPHP
$reactResponse = Psr7Bridge::fromV2ToV1($pivotResponse);Future versions of PivotPHP Core may include:
- Conditional Loading: Automatic detection and loading of appropriate implementations based on installed PSR-7 version
- Built-in Bridge: Native bridge classes for seamless conversion between PSR-7 versions
- Adapter Pattern: Factory methods that return compatible implementations
- For new projects: Use PSR-7 v2.0 for better type safety
- For existing projects with PSR-7 v1.x dependencies: Consider using a bridge library or waiting for native dual-version support
- For maximum compatibility: Implement your own PSR-7 adapter layer specific to your needs