<p dir="auto">Sometimes you need to parse and modify URL yourself. There is parse_url function in PHP. But it returns all components as array. Rebuilding the URL from the array is a little bit cumbersome because you need lots of checks like here <a href="http://stackoverflow.com/questions/4354904/php-parse-url-reverse-parsed-url#answer-31691249" rel="nofollow">http://stackoverflow.com/questions/4354904/php-parse-url-reverse-parsed-url#answer-31691249</a></p>
<p dir="auto">And there is also some hardcoded logic in UrlGenerator like this<br>
<a href="https://github.com/symfony/Routing/blob/master/Generator/UrlGenerator.php#L58">https://github.com/symfony/Routing/blob/master/Generator/UrlGenerator.php#L58</a></p>
<p dir="auto">So it's hard to build it the same way UrlGenerator does it. OFC one can use the generator for it but it's not usable for URLs which are not routed.</p>
<p dir="auto">I think it would be nice to move this logic to a new value object so one can use it for creating/modifying URLs. Like this<br>
<a href="https://github.com/nette/http/blob/master/src/Http/Url.php">https://github.com/nette/http/blob/master/src/Http/Url.php</a><br>
Not only UrlGenerator could use it. For example RedirectResponse is another candidate which could return it instead of a string so one can just for example safely append query parameter to it. I was solving this issue in my custom authentication failure handler which overrides the default symfony one and appends query parameter to the RedirectResponse.</p>
<p dir="auto">What do you think?</p>
<p dir="auto">EDIT: Or if it was too big change then at least moving the hardcoded logic from urlgenerator would also be useful. Maybe even just an utility class...</p>
<p dir="auto">Naïve list gathered with grep. Let's make using each of these usable, standalone, in a PSR-7 centric app, or just check if there is something to do, or decide to not do it.</p>
<h2 dir="auto">May handle PSR-7:</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Bridge/Doctrine (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98213202" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15414" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/15414/hovercard?comment_id=126414399&amp;comment_type=issue_comment" href="https://github.com/symfony/symfony/issues/15414#issuecomment-126414399">#15414 (comment)</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bridge/Monolog</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Bridge/Swiftmailer (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98213202" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15414" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/15414/hovercard?comment_id=126696544&amp;comment_type=issue_comment" href="https://github.com/symfony/symfony/issues/15414#issuecomment-126696544">#15414 (comment)</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bridge/Twig</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/Asset</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Component/Debug (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98228787" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15415" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/15415/hovercard" href="https://github.com/symfony/symfony/pull/15415">#15415</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98332503" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15418" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/15418/hovercard" href="https://github.com/symfony/symfony/pull/15418">#15418</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/Form</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/Routing</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/Security/Core</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Component/Security/Csrf (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98213202" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15414" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/15414/hovercard?comment_id=126429803&amp;comment_type=issue_comment" href="https://github.com/symfony/symfony/issues/15414#issuecomment-126429803">#15414 (comment)</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/Security/Http</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Component/Translation (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98213202" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15414" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/15414/hovercard?comment_id=126698024&amp;comment_type=issue_comment" href="https://github.com/symfony/symfony/issues/15414#issuecomment-126698024">#15414 (comment)</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Component/Validator (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="98395893" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/15421" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/15421/hovercard" href="https://github.com/symfony/symfony/pull/15421">#15421</a>)</li>
</ul>
<h2 dir="auto">May not handle PSR-7:</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/HttpFoundation</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Component/HttpKernel</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bundle/DebugBundle</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bundle/FrameworkBundle</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bundle/SecurityBundle</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bundle/TwigBundle</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Bundle/WebProfilerBundle</li>
</ul>