These are chat archives for ppi/framework

19th
Nov 2015
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:01
@dragoonis is your PSR-7 implementation in a tagged release!?
Paul Dragoonis
@dragoonis
Nov 19 2015 14:05
@AndrewCarterUK Yes, it’s not changed lately, but other parts have (in dev-master). I will make a new tag right now for dev-master - alpha4 or something
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:05
It's more that it shouldn't be advertised as a PSR-7 implementation as it is because it violates the spec.
Paul Dragoonis
@dragoonis
Nov 19 2015 14:07
our request/response objects should be PSR-7 compliant - if not please point out where
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:07
it's impossible to extend the symfony foundation objects to make them PSR-7 compliant
PSR-7 objects in their definition spec are immutable, symfony foundation ones are very mutable
Paul Dragoonis
@dragoonis
Nov 19 2015 14:10
yea, fair point, it’s why we’re looking to move over to SF bridge.
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:31
@dragoonis @KorvinSzanto problem solved?
not tested, but as an idea - make the framework pass around a request container which is the applications initial state of the request
when you hit a controller or action, then you pick which you want
Paul Dragoonis
@dragoonis
Nov 19 2015 14:32
I like it - what happens when somebody does things with one request, and it’s handed off to another part of the system and they use the other request
SF contains state, for example
you wanna set some content-dispositions in the PSR-7 guy, then another part of the system asks for $container->get(‘Response’)
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:33
well allowing mutability is where bugs creep in
it should probably actually clone the symfony request object before it returns it actually
Paul Dragoonis
@dragoonis
Nov 19 2015 14:34
So you’re saying you’ll always have immutability, from what’s initially built in the RequestContainer:: getPSR7Request() ? Yea?
Andrew Carter
@AndrewCarterUK
Nov 19 2015 14:35
I'm saying there should be one point where the application receives a request and defines a response
so this would usually be a controller action or an action class
the application should, through some mechanism, decide which request object it wants and then thats it's problem
if it wants to play around with it and hand it to services, it should do that directly
by injecting the request itself
services shouldn't be picking up the request object from the container
you'll never be PSR-7 compatible with that approach
if you've got a controller that uses symfony foundation
which wants to use a service that uses PSR-7, the best you can do is make the bridge service available
http://pastebin.com/Hed1Gxqk <-- that's probably more accurate (forgot the methods!)
Paul Dragoonis
@dragoonis
Nov 19 2015 18:49
I’m talking about PPI tonight - the stream will go live around 7:05pm GMT time - https://t.co/GJ72MiKMaX
Korvin Szanto
@KorvinSzanto
Nov 19 2015 20:06
@AndrewCarterUK the route dispatcher should be at the end of the request middleware though
You can't just keep two objects around because one is immutable, one is not
Legacy code is expecting the request to be mutable
new code is expecting the request to not be mutable
the only way I can think to support that is to recreate the PSR request from the symfony request after it changes
this isn't exactly what the symfony bridge does, they don't have a generic psr-7 request factory
they just have a diactoros factory that bootstraps a NEW request based on the symfony request
I kindof expect something like $psr_request = $psr_factory->updateRequest($psr_request, $symfony_request) : ServerRequestInterface
Paul Dragoonis
@dragoonis
Nov 19 2015 22:57
@KorvinSzanto did someone say “update” to immutable object ?!?!? :P
This message was deleted
Paul Dragoonis
@dragoonis
Nov 19 2015 23:04
/cc @AndrewCarterUK @dannym87 @noisebleed
Korvin Szanto
@KorvinSzanto
Nov 19 2015 23:39
@dragoonis I guess my point is that, while a symfony request exists, your psr-7 request is not the source of truth
if you create a symfony request from a PSR request, you can't just use both in parallel, you need to have one or the other
In the same way I can take an immutable array in other languages and copy it into a mutable array to change it
If I make that mutable array, I need to get a new immutable version out of it for that to make sense
otherwise, you lose any mutable changes