Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2023
Merged

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

merged 1 commit into from
May 17, 2023

Conversation

nicolas-grekas
Copy link
Contributor

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
Copy link
Contributor

dbu commented Apr 28, 2023

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
Copy link
Contributor Author

nicolas-grekas commented Apr 28, 2023

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
Copy link

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
Copy link
Contributor Author

PR rebased.

@dbu dbu merged commit 9b38270 into php-http:1.x May 17, 2023
@dbu
Copy link
Contributor

dbu commented May 17, 2023

alright, lets do this.

@nicolas-grekas nicolas-grekas deleted the drop-httplg-factory branch May 17, 2023 06:43
@dbu
Copy link
Contributor

dbu commented May 17, 2023

@aschempp
Copy link

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
Copy link

fritzmg commented May 17, 2023

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
Copy link
Contributor

dbu commented May 17, 2023

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
Copy link

fritzmg commented May 17, 2023

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
Copy link
Contributor

dbu commented May 17, 2023

@fritzmg damn, then its me again :/ will fix that in FriendsOfSymfony/FOSHttpCache#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
Copy link
Contributor

dbu commented May 17, 2023

@fritzmg
Copy link

fritzmg commented May 17, 2023

Works, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants