The Slim Framework implements a derivation of the Rack protocol. When
you instantiate a Slim application, it immediately inspects the
$_SERVER superglobal and derives a set of environment
variables that dictate application behavior.
A Slim application’s “environment” is an associative array of settings that are parsed once and made accessible to the Slim application and its middleware. You are free to modify the environment variables during runtime; changes will propagate immediately throughout the application.
When you instantiate a Slim application, the environment variables are derived from the
$_SERVER superglobal; you do
not need to set these yourself. However, you are free to modify or supplement these variables in Slim middleware.
These variables are fundamental to determining how your Slim application runs: the resource URI, the HTTP method, the HTTP request body, the URL query parameters, error output, and more. Middleware, described later, gives you the power to - among other things - manipulate environment variables before and/or after the Slim application is run.
The following text respectfully borrows the same information originally available at http://rack.rubyforge.org/doc/files/SPEC.html. The environment array must include these variables:
PATH_INFO, this can be used to create a fully qualified URL to an application resource. However, if
HTTP_HOSTis present, that should be used instead of this. This is required and may never be an empty string.
PATH_INFO, this can be used to create a fully qualified URL to any application resource. This is required and may never be an empty string.
The Slim application can store its own data in the environment, too. The environment array’s keys must contain at least
one dot, and should be prefixed uniquely (e.g. “prefix.foo”). The prefix slim. is reserved for use by Slim itself
and must not be used otherwise. The environment must not contain the keys
(use the versions without HTTP_). The CGI keys (named without a period) must have String values. There are the
slim.inputmust be a string.
REQUEST_METHODmust be a valid token.
SCRIPT_NAME, if non-empty, must start with “/”
PATH_INFO, if non-empty, must start with “/”
CONTENT_LENGTH, if given, must consist of digits only.
PATH_INFOmust be set.
PATH_INFOshould be “/” if
SCRIPT_NAMEnever should be “/”, but instead be an empty string.