php-http / message

HTTP Message related tools
http://php-http.org
MIT License
1.29k stars 41 forks source link

Remove direct dependency on php-http/message-factory #152

Closed nicolas-grekas closed 1 year ago

nicolas-grekas commented 1 year ago
Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets -
Documentation -
License MIT

php-http/message-factory contains only deprecated interfaces. It'd be great to not force users of this lib to install it. Note that all concerned classes are already deprecated since years.

dbu commented 1 year ago

this could be a bit disruptive in legacy applications.

how about we just do a version 2 of php-http/message where we drop the dependency and all deprecated code we have here in message?

nicolas-grekas commented 1 year ago

the solution is trivial: run the command mentioned in the exception message I don't think we need to care much about those legacy things...

derhansen commented 1 year ago

Now that php-http/message-factory has been marked as abandoned on packagist, I think this PR should be merged, since every PHP project depending on php-http/message will now see a Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead. notice when installing/updating dependencies.

nicolas-grekas commented 1 year ago

PR rebased.

dbu commented 1 year ago

alright, lets do this.

dbu commented 1 year ago

https://github.com/php-http/message/releases/tag/1.16.0

aschempp commented 1 year ago

This appears to break existing applications. We now get this exception in Contao when installing composer dependencies.

In MessageFactoryDiscovery.php line 29:

  No message factories found. To use Guzzle, Diactoros or Slim Framework fact  
  ories install php-http/message and the chosen message implementation.   
fritzmg commented 1 year ago

Note: php-http/message is installed in this case.

 [Http\Discovery\NotFoundException]                                                                         
  No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message 
  and the chosen message implementation.                                                                   

Exception trace:
  at vendor\php-http\discovery\src\MessageFactoryDiscovery.php:29
 Http\Discovery\MessageFactoryDiscovery::find() at vendor\friendsofsymfony\http-cache\src\ProxyClient\HttpProxyClient.php:63
 FOS\HttpCache\ProxyClient\HttpProxyClient->__construct() at var\cache\prod\Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer.php:1601
 Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer->getFosHttpCache_ProxyClient_SymfonyService() at var\cache\prod\Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer.php:1574
 Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer->getFosHttpCache_CacheManagerService() at var\cache\prod\Container4whLDxx\getFosHttpCache_EventListener_InvalidationService.php:22
 Container4whLDxx\getFosHttpCache_EventListener_InvalidationService::do() at var\cache\prod\Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer.php:656
 Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer->load() at var\cache\prod\Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer.php:1456
 Container4whLDxx\Contao_ManagerBundle_HttpKernel_ContaoKernelProdContainer->Container4whLDxx\{closure}() at 
vendor\symfony\event-dispatcher\EventDispatcher.php:267
 Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() at vendor\symfony\event-dispatcher\EventDispatcher.php:230
 Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at vendor\symfony\event-dispatcher\EventDispatcher.php:59
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at vendor\symfony\console\Application.php:1073
 Symfony\Component\Console\Application->doRunCommand() at vendor\symfony\framework-bundle\Console\Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at vendor\symfony\console\Application.php:301
 Symfony\Component\Console\Application->doRun() at vendor\symfony\framework-bundle\Console\Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at vendor\symfony\console\Application.php:171
 Symfony\Component\Console\Application->run() at vendor\contao\manager-bundle\bin\contao-console:38
 include() at vendor\bin\contao-console:120
 composer show php-http/message
name     : php-http/message
descrip. : HTTP Message related tools
keywords : http, message, psr-7
versions : * 1.16.0
dbu commented 1 year ago

the exception message in discovery seems wrong, it should explicitly talk about php-http/message-factory and not just php-http/message.

the quickfix for contao would be to require php-http/message-factory explicitly. the better fix would be to switch to the PSR-17 message factories instead of the httplug message factories. but depending on where those factories are used in contao, this could be a BC break for contao.

fritzmg commented 1 year ago

the quickfix for contao would be to require php-http/message-factory explicitly.

@dbu But php-http/message-factory is abandonded and when using the suggested replacement (psr/http-factory) the error still occurs.

but depending on where those factories are used in contao, this could be a BC break for contao.

They are not used by us at all. This error happens through a transient dependency (friendsofsymfony/http-cache).

dbu commented 1 year ago

@fritzmg damn, then its me again :/ will fix that in https://github.com/FriendsOfSymfony/FOSHttpCache/pull/543

i (or some contributor) should upgrade FOSHttpCache to use the PSR-17 mesage factories as it still relies on the legacy php-http message factories.

dbu commented 1 year ago

should be fixed now https://github.com/FriendsOfSymfony/FOSHttpCache/releases/tag/2.15.1

fritzmg commented 1 year ago

Works, thank you :)