CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.1 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.1
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Middleware
      • Session
      • TestSuite
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class ServerRequestFactory

Factory for making ServerRequest instances.

This adds in CakePHP specific behavior to populate the basePath and webroot attributes. Furthermore the Uri's path is corrected to only contain the 'virtual' path for the request.

Namespace: Cake\Http

Method Summary

  • createServerRequest() public

    Create a new server request.

  • fromGlobals() public static

    Create a request from the supplied superglobal values.

  • marshalBodyAndRequestMethod() protected static

    Sets the REQUEST_METHOD environment variable based on the simulated _method HTTP override value. The 'ORIGINAL_REQUEST_METHOD' is also preserved, if you want the read the non-simulated HTTP method the client used.

  • marshalFiles() protected static

    Process uploaded files and move things onto the parsed body.

Method Detail

createServerRequest() ¶ public

createServerRequest(string $method, UriInterface|string $uri, array $serverParams = []): Psr\Http\Message\ServerRequestInterface

Create a new server request.

Note that server-params are taken precisely as given - no parsing/processing of the given values is performed, and, in particular, no attempt is made to determine the HTTP method or URI, which must be provided explicitly.

Parameters
string $method

The HTTP method associated with the request.

UriInterface|string $uri

The URI associated with the request. If the value is a string, the factory MUST create a UriInterface instance based on it.

array $serverParams optional

Array of SAPI parameters with which to seed the generated request instance.

Returns
Psr\Http\Message\ServerRequestInterface

fromGlobals() ¶ public static

fromGlobals(array|null $server = null, array|null $query = null, array|null $parsedBody = null, array|null $cookies = null, array|null $files = null): Cake\Http\ServerRequest

Create a request from the supplied superglobal values.

If any argument is not supplied, the corresponding superglobal value will be used.

Parameters
array|null $server optional

$_SERVER superglobal

array|null $query optional

$_GET superglobal

array|null $parsedBody optional

$_POST superglobal

array|null $cookies optional

$_COOKIE superglobal

array|null $files optional

$_FILES superglobal

Returns
Cake\Http\ServerRequest
Throws
InvalidArgumentException
for invalid file values

marshalBodyAndRequestMethod() ¶ protected static

marshalBodyAndRequestMethod(array $parsedBody, Cake\Http\ServerRequest $request): Cake\Http\ServerRequest

Sets the REQUEST_METHOD environment variable based on the simulated _method HTTP override value. The 'ORIGINAL_REQUEST_METHOD' is also preserved, if you want the read the non-simulated HTTP method the client used.

Request body of content type "application/x-www-form-urlencoded" is parsed into array for PUT/PATCH/DELETE requests.

Parameters
array $parsedBody

Parsed body.

Cake\Http\ServerRequest $request

Request instance.

Returns
Cake\Http\ServerRequest

marshalFiles() ¶ protected static

marshalFiles(array $files, Cake\Http\ServerRequest $request): Cake\Http\ServerRequest

Process uploaded files and move things onto the parsed body.

Parameters
array $files

Files array for normalization and merging in parsed body.

Cake\Http\ServerRequest $request

Request instance.

Returns
Cake\Http\ServerRequest
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs