webservco / http
A PHP component/library.
v0.11.0
2024-08-23 15:59 UTC
Requires
Requires (Dev)
- pds/skeleton: ^1
- phan/phan: ^5
- php-parallel-lint/php-console-highlighter: ^1
- php-parallel-lint/php-parallel-lint: ^1
- phpcompatibility/php-compatibility: ^9
- phpmd/phpmd: ^2
- phpstan/phpstan: ^1
- phpstan/phpstan-phpunit: ^1
- phpstan/phpstan-strict-rules: ^1
- phpunit/phpunit: ^10
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^3
- vimeo/psalm: ^5
- webservco/coding-standards: ^0
- webservco/component-common: ^0
README
A minimalist PHP PSR implementation.
Implements
Provides
psr/http-factory-implementation
psr/http-message-implementation
Troubleshooting
php-http/discovery
If using a project/library that requires php-http/discovery
, a list of 9 "well-known" implementations is forced.
Workaround to install custom implementations of your choice:
- Create custom strategy - implement
Http\Discovery\Strategy\DiscoveryStrategy
:
<?php declare(strict_types=1); namespace Project\Factory\Http\Discovery; use Http\Discovery\Strategy\DiscoveryStrategy; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\StreamFactoryInterface; // A RequestFactoryInterface implementation of your choice: use WebServCo\Http\Factory\Message\Request\RequestFactory; // A StreamFactoryInterface implementation of your choice: use WebServCo\Http\Factory\Message\Stream\StreamFactory; final class Psr17DiscoveryStrategy implements DiscoveryStrategy { /** * @inheritDoc * @param string $type * @return array<array<string, string>> */ public static function getCandidates($type) { if ($type === RequestFactoryInterface::class) { return [ [ 'class' => RequestFactory::class, ], ]; } if ($type === StreamFactoryInterface::class) { return [ [ 'class' => StreamFactory::class, ], ]; } return []; } }
- Use custom strategy:
use Http\Discovery\ClassDiscovery; use Project\Factory\Http\Discovery\Psr17DiscoveryStrategy; // Before instantiating the class that uses `php-http/discovery` ClassDiscovery::prependStrategy(Psr17DiscoveryStrategy::class);
- Workaround credit: Popus Razvan Adrian
- Documentation: Strategies