Skip to content

Commit

Permalink
URI (#53731)
Browse files Browse the repository at this point in the history
URI parsing and mutation powered by league/uri.
  • Loading branch information
taylorotwell authored Dec 9, 2024
1 parent 36b09b7 commit c9bdfed
Show file tree
Hide file tree
Showing 7 changed files with 598 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"league/commonmark": "^2.2.1",
"league/flysystem": "^3.25.1",
"league/flysystem-local": "^3.25.1",
"league/uri": "^7.5.1",
"monolog/monolog": "^3.0",
"nesbot/carbon": "^2.72.2|^3.4",
"nunomaduro/termwind": "^2.0",
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Illuminate\Support\AggregateServiceProvider;
use Illuminate\Support\Defer\DeferredCallbackCollection;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Uri;
use Illuminate\Testing\LoggedExceptionCollection;
use Illuminate\Testing\ParallelTestingServiceProvider;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -89,6 +90,7 @@ public function register()
$this->registerDumper();
$this->registerRequestValidation();
$this->registerRequestSignatureValidation();
$this->registerUriUrlGeneration();
$this->registerDeferHandler();
$this->registerExceptionTracking();
$this->registerExceptionRenderer();
Expand Down Expand Up @@ -188,6 +190,16 @@ public function registerRequestSignatureValidation()
});
}

/**
* Register the "defer" function termination handler.
*
* @return void
*/
protected function registerUriUrlGeneration()
{
Uri::setUrlGeneratorResolver(fn () => app('url'));
}

/**
* Register the "defer" function termination handler.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\Uri;
use RuntimeException;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\InputBag;
Expand Down Expand Up @@ -91,6 +92,16 @@ public function method()
return $this->getMethod();
}

/**
* Get a URI instance for the request.
*
* @return \Illuminate\Support\Uri
*/
public function uri()
{
return Uri::of($this->fullUrl());
}

/**
* Get the root URL for the application.
*
Expand Down
Loading

0 comments on commit c9bdfed

Please sign in to comment.