Creates and return a new request object. All get, head, etc. methods are generated via this method.
Symfony\Component\Routing\Exception\RouteNotFoundException
If the named route doesn't exist
Symfony\Component\Routing\Exception\MissingMandatoryParametersException
When some parameters are missing that are mandatory for the route
Symfony\Component\Routing\Exception\InvalidParameterException
When a parameter value for a placeholder is not correct because it
does not match the requirement
If URL is empty, only the base URL will be used:
::createRequest('GET')
=> http://localhost
If URI is used, add the base URL to generate the proper URL to request
::createRequest('GET', '/api/users')
=> http://localhost/api/users
If route name is used, will first generate the URI before applying the base URL; can use parameters
::createRequest('GET', 'users_cget')
=> http://localhost/api/users
::createRequest('GET', 'users_get', null, ['parameters' => ['id' => 14]])
=> http://localhost/api/users/14
Can also apply other options
::createRequest('GET', null, null, ['query' => ['id' => 14, 'filter' => ['order' => ['startAt' => 'desc']]])
=> http://localhost/api?id=14&filter[where][name]=john
Or if you have just one query
::createRequest('GET', null, null, ['query' => 'filter[where][name]=john')
=> http://localhost/api?filter[where][name]=john