Part of #2492955: [meta] PSR-7 support
This issue is just to add the dependent libraries to Drupal core and register them with the container.
https://packagist.org/packages/symfony/psr-http-message-bridge
https://packagist.org/packages/zendframework/zend-diactoros
In addition to adding the composer libraries we also should register the two factory services with the container: HttpFoundationFactory and DiactorosFactory.
See the parent issue for the larger intent.
This issue is nominally blocked on #2470693: Upgrade to Symfony 2.7.0 but only for reroll-difficulty reasons.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | include_symfony_psr_7-2497691-31.patch | 264.89 KB | cilefen |
| #31 | include_symfony_psr_7-2497691-31-do-not-test.patch | 7.37 KB | cilefen |
| #28 | 2497691-psr7-do-not-test.patch | 7.37 KB | Crell |
| #28 | 2497691-psr7.patch | 265.23 KB | Crell |
Comments
Comment #1
Crell commentedComment #2
cilefen commentedI am not sure what to name those services.
Comment #3
marvin_b8 commentedWe have a problem with the php version requirements of drupal and zend diactoros.
https://packagist.org/packages/zendframework/zend-diactoros
php: >=5.5
Drupal 8: PHP 5.4.5 or higher
its work for me but ....
Comment #5
Crell commentedThere is a tagged 0.1 release. Why not use that?
Maybe call this psr7.factory, to avoid the silly name? Hm. Open to suggestions here.
Can you include a diff in the future that is just the changes outside of vendor? It makes it much easier to review. We'll commit the patch with vendor but it's a lot nicer to review one without. Thanks!
Comment #6
cilefen commentedComment #7
dawehnerSo does symfony promises similar APIs even before 1.0?
Comment #8
alexpott@Crell in #2492955: [meta] PSR-7 support you said you nudged the maintianers of this to make it php 5.4 compatible - did you create a PR? If so is there a link?
Comment #9
Crell commentedNo PR, but a Twitter discussion: https://twitter.com/Crell/status/604787960127582208 (summary: MWOP says they'll think about it)
I also asked the Symfonians about stability of the bridge library's API: https://twitter.com/Crell/status/605124382696955904 (summary: Shouldn't change, esp. since it's such a small lib, but even if it does stable should be out before 8.0.0 anyway and it needn't be public facing for our user base)
(Feels weird to be posting Twitter threads to d.o as documentation, but welcome to the age of social media...)
Comment #11
Crell commentedDoes anyone else have thoughts on the service names, while we're waiting on confirmation from Alex?
Comment #13
cilefen commented#2497693: Add PSR-7 to Symfony Response View listener has:
symfony.psr7.http_foundation_factory
So in that paradigm we would have:
zend.psr7.diactoros_factory
Comment #14
Crell commentedWe're not namespacing by the 3rd party library anywhere else. I don't see a reason to do so here.
Comment #15
Crell commentedalexpott: https://github.com/zendframework/zend-diactoros/pull/48
PR there to drop the version requirement for Diactoros, at least for the time being. Assuming that's merged, the next release would be compatible with us with no additional version issues. If that unblocks moving forward, it would be good to mention that on the thread to encourage MWOP to commit it sooner rather than later. :-)
If green lit, we just need a reroll here and a verdict on the service names. (Alex, I defer to you if you have any strong preferences.)
Comment #16
dawehnerI'd prefer more something like request_from_psr7.factory psr7_from_request.factory ... which library we use is a detail IMHO and might be different in the future
Comment #17
Crell commentedRerolling, with new service names similar to #16.
Comment #18
alexpottThis looks superconfusing to me... I guess (and it only a guess) that
psr7_request.factoryconverts a PSR7 request to a Symfony request andrequest_psr7.factorydoes it the other way.I think
psr7_to_symfony.request.factoryandsymfony_to_psr7.request.factoryis better since it is more explicit.Comment #19
Crell commentedNot my favorite names, but eh, I'd rather get the libraries in. :-)
New patches per #18. I forgot to make an interdiff before rebasing, but the only change is the service rename per #18.
Comment #20
alexpott@Crell names here are important so let's try and work to towards a consensus. My problem with psr7_request/request_psr7 is that a PSR7 request is a thing so I would expect psr7_request.factory to produce psr7 requests but it does not to. It converts psr7 requests into a Symphony request object.
Comment #21
Crell commentedWell, my issue is more that service names feel like they should be nouns. "foo_to_bar" et al feels more like a verb (method name). Dropping the "to" in the middle was the best suggestion I had though.
I've pinged a Symfonian for their input, but worst case scenario we have somewhat odd names for 2 services that rarely will any module developers touch directly. I just don't want to get this set of issues hung up on a bikeshed. :-)
Comment #22
fabianx commentedThose are converter services, so why not something like:
converter.psr7_request.factory
converter.request_psr7.factory
Not sure we need even the factory specification (without looking at the patch):
converter.psr7_to_request
converter.request_to_psr7
or
converter.psr7_request
converter.request_psr7
Thoughts?
Comment #23
Crell commentedData point: In Symfony 2.7, the services are registered via the SensioFrameworkExtraBundle. Its service names are:
sensio_framework_extra.psr7.http_message_factory
sensio_framework_extra.psr7.http_foundation_factory
Obviously we don't need the first part, but what about:
psr7.http_message_factory
psr7.http_foundation_factory
(The first producing PSR7 messages, the second producing HttpFoundation classes.)
(HT to Ryan Weaver for linking me to those.)
Comment #24
Crell commentedI am going to take silence as approval, so here's a version with the service names from #23.
Can haz commits? Or RTBCz?
Comment #25
dawehner+1
Comment #26
cilefen commentedI am not sold on the meaning of "factory" in the service names.
Comment #27
dawehnerThe helpful thing of putting factory in there is that it actually explains, what its doing, which is IMHO an important piece of the puzzle.
Comment #28
Crell commentedA new version of Diactoros was just released. Rerolling for that. No other changes.
Comment #29
dawehnerAlright, let's see whether the POST request makes it.
Comment #31
cilefen commentedComment #32
jibranBack to RTBC as per #27
Comment #33
alexpottOkay - let's join the PSR-7 revolution :) Drupal 8 has had a long term goal to be interoperable with other frameworks as pointed out by @yched in the meta issue:
Given the lack of disruption and the avenues for this opens up, committed a9dd72b and pushed to 8.0.x. Thanks!