Skip to content
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

4.x - Port RouteCollector::fullUrlFor() #2638

merged 2 commits into from Apr 20, 2019


None yet
2 participants
Copy link

commented Apr 20, 2019

This is pull 4 out of 7 to complete the goals set in #2604

The functionality is ported from #2493 and adds the ability to create full urls relative to a UriInterface.

It also changes the deprecation of the method urlFor() to pathFor() since it was determined that urlFor() is a more used terminology.

Example usage:

use Slim\App;
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Http\ServerRequest;
use Slim\Middleware\ErrorMiddleware;
use Slim\Psr7\Factory\ResponseFactory;
use Slim\Psr7\Factory\ServerRequestFactory;
use Slim\Psr7\Factory\StreamFactory;

$responseFactory = new DecoratedResponseFactory(new ResponseFactory(), new StreamFactory());
$app = new App($responseFactory);
$routeCollector = $app->getRouteCollector();

 * The base app url would be for example:
 * If you wanted to generate a fully qualified URL from within a route
 * you would do something like the following
$route = $app->get('/hello/{name}', function ($request, $response, $args) use ($routeCollector) {
    /** @var RouteInterface $route */
    $route = $request->getAttribute('route');
    $routeName = $route->getName();

    $uri = $request->getUri();

     * $fullyQualifiedUrl would be:
    $fullyQualifiedUrl = $routeCollector->fullUrlFor($uri, $routeName, ['name' => 'world']);

    return $response;

$request = new ServerRequest(ServerRequestFactory::createFromGlobals());

@l0gicgate l0gicgate added the Slim 4 label Apr 20, 2019

@l0gicgate l0gicgate added this to the 4.0 milestone Apr 20, 2019


This comment has been minimized.

Copy link

commented Apr 20, 2019

Coverage Status

Coverage increased (+0.01%) to 98.527% when pulling e0346e6 on l0gicgate:4.x-FullUrlFor into 341e1bd on slimphp:4.x.

@l0gicgate l0gicgate merged commit d5497de into slimphp:4.x Apr 20, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage increased (+0.01%) to 98.527%

@l0gicgate l0gicgate referenced this pull request Apr 20, 2019


[DRAFT] 4.x Refactor Routing #2604

7 of 7 tasks complete

@l0gicgate l0gicgate deleted the l0gicgate:4.x-FullUrlFor branch Apr 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.