[PSR-17] UriFactoryInterface::createUri

57 views
Skip to first unread message

ignace nyamagana

unread,
Jan 14, 2025, 1:51:12 PMJan 14
to PHP Framework Interoperability Group
While working on the league/uri I stumble upon the following inconsistency regarding URI creation with the following URL: " http://example.com/p th?q#f "

using League\uri implementation: this will throw
using Diactoros implementation: "/%20http://example.com/p%20th?q#f%20"
using Guzzle implementation: " http://example.com/p%20th?q#f%20"
using Slim/Nyholm implementation: "%20http://example.com/p%20th?q#f%20"

According to RFC3986 spaces are forbidden in URI but since all the other implementations except for league\uri depends on parse_url part of the result is possible as parse_url allow spaces in URL.

Is this considered a bug or a lack of clarification in PSR-17 ? In all cases would it be possible to consider adding a test suite to covers basic actions regarding PSR7/PSR17 to allow fixing those cases which are not cover by both PSR 

da...@liip.ch

unread,
Jan 14, 2025, 4:33:12 PMJan 14
to PHP Framework Interoperability Group
interesting observation, thanks for bringing this up.

I think you touch a general concern and would like to react on your last sentence...

i think it would be interesting if each technical PSR would come with an "official" test suite that runs functional tests of the specification. that would further clarify the intent of the specification and improve compatibility between implementations. if this is something the FIG would consider, i would offer to help draft the pattern for specification integration tests. i did that for a large API with the phpcr-api-tests [1], allowing for the fact that implementations not necessarily implement the complete spec or need to skip specific tests until issues are fixed, so that they can require green tests before achieving full spec compliancy.

at php-http, we maintain a psr7 integration test suite [2] that we run with the known psr7 implementations. some of those implementations also build their repository with the integration tests. if the FIG is interested to provide integration test suites for the PSRs, we would be happy to donate this repository to the FIG  to start with an existing test suite that is used in the wild.

Reply all
Reply to author
Forward
0 new messages