Skip to content

Commit

Permalink
Update request-response.rst
Browse files Browse the repository at this point in the history
Updated the `Environment Variables (from $_SERVER and $_ENV)` section to suggest `getEnv` and `withEnv`
  • Loading branch information
ToX82 authored Apr 5, 2021
1 parent e28e88e commit 02f8ccf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions en/controllers/request-response.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ Additional parameters for the decoding function can be passed as arguments to
Environment Variables (from $_SERVER and $_ENV)
-----------------------------------------------

.. php:method:: env($key, $value = null)
.. php:method:: putenv($key, $value = null)
``ServerRequest::env()`` is a wrapper for ``env()`` global function and acts as
``ServerRequest::getEnv()`` is a wrapper for ``getenv()`` global function and acts as
a getter/setter for environment variables without having to modify globals
``$_SERVER`` and ``$_ENV``::

// Get the host
$host = $this->request->env('HTTP_HOST');
$host = $this->request->getEnv('HTTP_HOST');

// Set a value, generally helpful in testing.
$this->request->env('REQUEST_METHOD', 'POST');
$this->request->withEnv('REQUEST_METHOD', 'POST');

To access all the environment variables in a request use ``getServerParams()``::

Expand Down

0 comments on commit 02f8ccf

Please sign in to comment.