Helpers

    Fetch the request’s content type (e.g. “application/json;charset=utf-8”):

    Media Type

    Fetch the request’s media type (e.g. “application/json”):

    1. $req = $app->request;
    2. $req->getMediaType();

    Media Type Params

    Fetch the request’s media type parameters (e.g. [charset => “utf-8”]):

    1. <?php
    2. $req = $app->request;
    3. $req->getMediaTypeParams();

    Content Charset

    Fetch the request’s content character set (e.g. “utf-8”):

    1. <?php
    2. $req = $app->request;
    3. $req->getContentCharset();

    Host

    Fetch the request’s host (e.g. “slimframework.com”):

    1. <?php
    2. $req->getHost();

    Host with Port

    Fetch the request’s host with port (e.g. “slimframework.com:80”):

    1. <?php
    2. $req = $app->request;
    3. $req->getHostWithPort();

    Port

    Fetch the request’s port (e.g. 80):

    1. $req = $app->request;
    2. $req->getPort();

    Fetch the request’s scheme (e.g. “http” or “https”):

    Path

    1. <?php
    2. $req = $app->request;

    URL

    Fetch the request’s URL (scheme + host [ + port if non-standard ]):

    1. <?php
    2. $req = $app->request;
    3. $req->getUrl();

    IP Address

    Fetch the request’s IP address:

    1. <?php
    2. $req = $app->request;
    3. $req->getIp();

    Fetch the request’s referrer:

    User Agent

    Fetch the request’s user agent string:

    1. <?php
    2. $req = $app->request;
    3. $req->getUserAgent();