diff --git a/CHANGELOG.md b/CHANGELOG.md index a59c2480..e06544dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.0 +--- + + * Remove PSR-7 support + 5.6 --- diff --git a/composer.json b/composer.json index 53e99560..1b11b6f5 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "doctrine/dbal": "^2.10|^3.0", "doctrine/doctrine-bundle": "^1.11|^2.0", "doctrine/orm": "^2.5", - "nyholm/psr7": "^1.1", "symfony/browser-kit": "^4.4|^5.0", "symfony/doctrine-bridge": "^4.4|^5.0", "symfony/dom-crawler": "^4.4|^5.0", @@ -31,7 +30,6 @@ "symfony/monolog-bundle": "^3.2", "symfony/monolog-bridge": "^4.0|^5.0", "symfony/phpunit-bridge": "^4.4.9|^5.0.9", - "symfony/psr-http-message-bridge": "^1.1", "symfony/security-bundle": "^4.4|^5.0", "symfony/twig-bundle": "^4.4|^5.0", "symfony/yaml": "^4.4|^5.0", @@ -58,7 +56,7 @@ }, "extra": { "branch-alias": { - "dev-master": "5.6.x-dev" + "dev-master": "6.0.x-dev" } } } diff --git a/src/DependencyInjection/SensioFrameworkExtraExtension.php b/src/DependencyInjection/SensioFrameworkExtraExtension.php index 39ebe556..f949364c 100644 --- a/src/DependencyInjection/SensioFrameworkExtraExtension.php +++ b/src/DependencyInjection/SensioFrameworkExtraExtension.php @@ -11,7 +11,6 @@ namespace Sensio\Bundle\FrameworkExtraBundle\DependencyInjection; -use Psr\Http\Message\StreamFactoryInterface; use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Resource\ClassExistenceResource; @@ -103,14 +102,6 @@ public function load(array $configs, ContainerBuilder $container) ->addArgument($config['templating']['controller_patterns']); } - if ($config['psr_message']['enabled']) { - $loader->load('psr7.xml'); - - if (!interface_exists(StreamFactoryInterface::class)) { - $definitionsToRemove[] = 'sensio_framework_extra.psr7.argument_value_resolver.server_request'; - } - } - foreach ($definitionsToRemove as $definition) { $container->removeDefinition($definition); } diff --git a/src/EventListener/PsrResponseListener.php b/src/EventListener/PsrResponseListener.php deleted file mode 100644 index bcdb69ad..00000000 --- a/src/EventListener/PsrResponseListener.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sensio\Bundle\FrameworkExtraBundle\EventListener; - -use Psr\Http\Message\ResponseInterface; -use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\KernelEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Converts PSR-7 Response to HttpFoundation Response using the bridge. - * - * @author Kévin Dunglas - */ -class PsrResponseListener implements EventSubscriberInterface -{ - /** - * @var HttpFoundationFactoryInterface - */ - private $httpFoundationFactory; - - public function __construct(HttpFoundationFactoryInterface $httpFoundationFactory) - { - $this->httpFoundationFactory = $httpFoundationFactory; - } - - /** - * Do the conversion if applicable and update the response of the event. - */ - public function onKernelView(KernelEvent $event) - { - $controllerResult = $event->getControllerResult(); - - if (!$controllerResult instanceof ResponseInterface) { - return; - } - - $event->setResponse($this->httpFoundationFactory->createResponse($controllerResult)); - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return [ - KernelEvents::VIEW => 'onKernelView', - ]; - } -} diff --git a/src/Request/ArgumentValueResolver/Psr7ServerRequestResolver.php b/src/Request/ArgumentValueResolver/Psr7ServerRequestResolver.php deleted file mode 100644 index 01e03432..00000000 --- a/src/Request/ArgumentValueResolver/Psr7ServerRequestResolver.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sensio\Bundle\FrameworkExtraBundle\Request\ArgumentValueResolver; - -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Injects the RequestInterface, MessageInterface or ServerRequestInterface when requested. - * - * @author Iltar van der Berg - */ -final class Psr7ServerRequestResolver implements ArgumentValueResolverInterface -{ - private static $supportedTypes = [ - 'Psr\Http\Message\ServerRequestInterface' => true, - 'Psr\Http\Message\RequestInterface' => true, - 'Psr\Http\Message\MessageInterface' => true, - ]; - - private $httpMessageFactory; - - public function __construct(HttpMessageFactoryInterface $httpMessageFactory) - { - $this->httpMessageFactory = $httpMessageFactory; - } - - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return isset(self::$supportedTypes[$argument->getType()]); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $this->httpMessageFactory->createRequest($request); - } -} diff --git a/src/Resources/config/psr7.xml b/src/Resources/config/psr7.xml deleted file mode 100644 index 7fdf5418..00000000 --- a/src/Resources/config/psr7.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/doc/index.rst b/src/Resources/doc/index.rst index 85f354de..5ef7be58 100644 --- a/src/Resources/doc/index.rst +++ b/src/Resources/doc/index.rst @@ -35,7 +35,6 @@ The default configuration is as follow: view: { annotations: true } cache: { annotations: true } security: { annotations: true } - psr_message: { enabled: false } # Defaults to true if the PSR-7 bridge is installed .. code-block:: xml @@ -47,7 +46,6 @@ The default configuration is as follow: - .. code-block:: php @@ -59,7 +57,6 @@ The default configuration is as follow: 'view' => array('annotations' => true), 'cache' => array('annotations' => true), 'security' => array('annotations' => true), - 'psr_message' => array('enabled' => false), // Defaults to true if the PSR-7 bridge is installed )); You can disable some annotations and conventions by defining one or more @@ -162,45 +159,4 @@ example: resource: "@AnnotRoutingBundle/Controller" type: annotation -PSR-7 support -------------- - -SensioFrameworkExtraBundle provides support for HTTP messages interfaces defined -in `PSR-7`_. It allows to inject instances of ``Psr\Http\Message\ServerRequestInterface`` -and to return instances of ``Psr\Http\Message\ResponseInterface`` in controllers. - -To enable this feature, `the HttpFoundation to PSR-7 bridge`_ and `autowiring -aliases for PSR-17`_ must be installed: - -.. code-block:: bash - - $ composer require symfony/psr-http-message-bridge nyholm/psr7 - -Then, PSR-7 messages can be used directly in controllers like in the following code -snippet:: - - namespace AppBundle\Controller; - - use Psr\Http\Message\ResponseFactoryInterface; - use Psr\Http\Message\ServerRequestInterface; - - class DefaultController - { - public function index(ServerRequestInterface $request, ResponseFactoryInterface $responseFactory) - { - // Interact with the PSR-7 request - - $response = $responseFactory->createResponse(); - // Interact with the PSR-7 response - - return $response; - } - } - -Note that internally, Symfony always use :class:`Symfony\\Component\\HttpFoundation\\Request` -and :class:`Symfony\\Component\\HttpFoundation\\Response` instances. - .. _`SensioFrameworkExtraBundle`: https://github.com/sensiolabs/SensioFrameworkExtraBundle -.. _`PSR-7`: http://www.php-fig.org/psr/psr-7/ -.. _`the HttpFoundation to PSR-7 bridge`: https://github.com/symfony/psr-http-message-bridge -.. _`autowiring aliases for PSR-17`: https://github.com/symfony/recipes/blob/master/nyholm/psr7/1.0/config/packages/nyholm_psr7.yaml diff --git a/tests/Functional/Psr7RequestTest.php b/tests/Functional/Psr7RequestTest.php deleted file mode 100644 index 44d5bd88..00000000 --- a/tests/Functional/Psr7RequestTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class Psr7RequestTest extends WebTestCase -{ - /** - * @dataProvider urlProvider - */ - public function testController($url) - { - $client = self::createClient(); - $crawler = $client->request('GET', $url); - - $this->assertEquals('ok', $crawler->filterXPath('//body')->html()); - } - - public static function urlProvider() - { - return [ - ['/action-arguments/normal/'], - ['/action-arguments/invoke/'], - ]; - } -}