-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: add URIFactory #7239
feat: add URIFactory #7239
Conversation
When registering Exception Handler, Request object was generated. But it was too early, and difficult to understand.
baseURL should not be empty.
This class does not work yet.
816dbcc
to
516a76a
Compare
516a76a
to
d5d34ec
Compare
public function __construct(array &$server, array &$get, App $appConfig) | ||
{ | ||
$this->server = &$server; | ||
$this->get = &$get; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think passing by reference, which means modifying superglobal arrays, is the right approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the right approach?
In my opinion, two factories are needed To create a separate class that works directly with |
How do you create Request object without URI object? |
Say hello to the framework architects for the URI class in the Request constructor. |
Sorry, I don't get what you say at all. |
The URI class depends on the Request class for incoming requests because the Request class must provide access to a copy of _SERVER. Therefore, making the Request class dependent on the URI is a framework architecture error. I don't know who designed these classes. |
Indeed.
Who designed does not matter. |
I don't know.
public function __constructor (protected array $query = [], protected array $request = [], protected array $server = []) {}
// and factory
public static function createFromGlobals(): Request
{
$request = new static($_GET, $_REQUEST, $_SERVER);
return $request->withUri(Uri::createFromRequest($request));
}
if (empty($userAgent)) {
throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
}
$this->uri = $uri ?? URI::createFromRequest($this); Or something similar. |
86bfab5
to
295a486
Compare
Needs #7232
Description
Add
URIFactory
to create the current URI object.To create the current URI object before the Request object. Also, to remove all URI adjustment processing currently performed in the constructor of the Request object.
This PR does not change any existing features yet.
URIFactory::createFromGlobals()
URI::setRoutePath()
andURI::getRoutePath()
Checklist: