Settings

mode

This is an identifier for the application’s current mode of operation. The mode does not affect a Slim application’sinternal functionality. Instead, the mode is only for you to optionally invoke your own code for a given mode with theconfigMode() application method.

The application mode is declared during instantiation, either as an environment variable or as an argument to theSlim application constructor. It cannot be changed afterward. The mode may be anything you want — “development”,“test”, and “production” are typical, but you are free to use anything you want (e.g. “foo”).

  1. <?php
  2. $app = new \Slim\Slim(array(
  3. 'mode' => 'development'
  4. ));
  • Data Type
  • string
  • Default Value
  • “development”

debug

Heads Up! Slim converts errors into ErrorException instances.

If debugging is enabled, Slim will use its built-in error handler to display diagnostic information for uncaughtExceptions. If debugging is disabled, Slim will instead invoke your custom error handler, passing it the otherwiseuncaught Exception as its first and only argument.

  1. <?php
  2. $app = new \Slim\Slim(array(
  3. 'debug' => true
  4. ));
  • Data Type
  • boolean
  • Default Value
  • true

log.writer

Use a custom log writer to direct logged messages to the appropriate output destination. By default, Slim’s logger willwrite logged messages to STDERR. If you use a custom log writer, it must implement this interface:

  1. public write(mixed $message, int $level);

The write() method is responsible for sending the logged message (not necessarily a string) to the appropriate outputdestination (e.g. a text file, a database, or a remote web service).

To specify a custom log writer after instantiation you must access Slim’s logger directly and use its setWriter() method:

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'log.writer' => new \My\LogWriter()
  5. ));
  6. // After instantiation
  7. $log = $app->getLog();
  8. $log->setWriter(new \My\LogWriter());
  • Data Type
  • mixed
  • Default Value
  • \Slim\LogWriter

log.level

Heads Up! Use the constants defined in \Slim\Log instead of integers.

Slim has these log levels:

  • \Slim\Log::EMERGENCY
  • \Slim\Log::ALERT
  • \Slim\Log::CRITICAL
  • \Slim\Log::ERROR
  • \Slim\Log::WARN
  • \Slim\Log::NOTICE
  • \Slim\Log::INFO
  • \Slim\Log::DEBUGThe log.level application setting determines which logged messages will be honored and which will be ignored.For example, if the log.level setting is \Slim\Log::INFO, debug messages will be ignored while info, warn,error, and fatal messages will be logged.

To change this setting after instantiation you must access Slim’s logger directly and use its setLevel() method.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'log.level' => \Slim\Log::DEBUG
  5. ));
  6. // After instantiation
  7. $log = $app->getLog();
  8. $log->setLevel(\Slim\Log::WARN);
  • Data Type
  • integer
  • Default Value
  • \Slim\Log::DEBUG

log.enabled

This enables or disables Slim’s logger. To change this setting after instantiation you need to access Slim’s loggerdirectly and use its setEnabled() method.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'log.enabled' => true
  5. ));
  6. // After instantiation
  7. $log = $app->getLog();
  8. $log->setEnabled(true);
  • Data Type
  • boolean
  • Default Value
  • true

templates.path

The relative or absolute path to the filesystem directory that contains your Slim application’s template files.This path is referenced by the Slim application’s View to fetch and render templates.

To change this setting after instantiation you need to access Slim’s view directly and use its setTemplatesDirectory()method.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'templates.path' => './templates'
  5. ));
  6. // After instantiation
  7. $view = $app->view();
  8. $view->setTemplatesDirectory('./templates');
  • Data Type
  • string
  • Default Value
  • ”./templates”

view

The View class or instance used by the Slim application. To change this setting after instantiation you need touse the Slim application’s view() method.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'view' => new \My\View()
  5. ));
  6. // After instantiation
  7. $app->view(new \My\View());
  • Data Type
  • string\Slim\View

  • Default Value

  • \Slim\View

cookies.encrypt

Determines if the Slim app should encrypt its HTTP cookies.

  1. <?php
  2. $app = new \Slim\Slim(array(
  3. 'cookies.encrypt' => true
  4. ));
  • Data Type
  • boolean
  • Default Value
  • false

cookies.lifetime

Determines the lifetime of HTTP cookies created by the Slim application. If this is an integer, it must be a validUNIX timestamp at which the cookie expires. If this is a string, it is parsed by the strtotime() function to extrapolatea valid UNIX timestamp at which the cookie expires.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.lifetime' => '20 minutes'
  5. ));
  6. // After instantiation
  7. $app->config('cookies.lifetime', '20 minutes');
  • Data Type
  • integerstring

  • Default Value

  • “20 minutes”

cookies.path

Determines the default HTTP cookie path if none is specified when invoking the Slim application’s setCookie() orsetEncryptedCookie() methods.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.path' => '/'
  5. ));
  6. // After instantiation
  7. $app->config('cookies.path', '/');
  • Data Type
  • string
  • Default Value
  • ”/”

cookies.domain

Determines the default HTTP cookie domain if none specified when invoking the Slim application’s setCookie() orsetEncryptedCookie() methods.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.domain' => 'domain.com'
  5. ));
  6. // After instantiation
  7. $app->config('cookies.domain', 'domain.com');
  • Data Type
  • string
  • Default Value
  • null

cookies.secure

Determines whether or not cookies are delivered only via HTTPS. You may override this setting when invokingthe Slim application’s setCookie() or setEncryptedCookie() methods.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.secure' => false
  5. ));
  6. // After instantiation
  7. $app->config('cookies.secure', false);
  • Data Type
  • boolean
  • Default Value
  • false

cookies.httponly

Determines whether cookies should be accessible through client side scripts (false = accessible). You may override this setting when invokingthe Slim application’s setCookie() or setEncryptedCookie() methods.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.httponly' => false
  5. ));
  6. // After instantiation
  7. $app->config('cookies.httponly', false);
  • Data Type
  • boolean
  • Default Value
  • false

cookies.secret_key

The secret key used for cookie encryption. You should change this setting if you use encrypted HTTP cookiesin your Slim application.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.secret_key' => 'secret'
  5. ));
  6. // After instantiation
  7. $app->config('cookies.secret_key', 'secret');
  • Data Type
  • string
  • Default Value
  • “CHANGE_ME”

cookies.cipher

The mcrypt cipher used for HTTP cookie encryption. See available ciphers.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.cipher' => MCRYPT_RIJNDAEL_256
  5. ));
  6. // After instantiation
  7. $app->config('cookies.cipher', MCRYPT_RIJNDAEL_256);
  • Data Type
  • integer
  • Default Value
  • MCRYPT_RIJNDAEL_256

cookies.cipher_mode

The mcrypt cipher mode used for HTTP cookie encryption. See available cipher modes.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'cookies.cipher_mode' => MCRYPT_MODE_CBC
  5. ));
  6. // After instantiation
  7. $app->config('cookies.cipher_mode', MCRYPT_MODE_CBC);
  • Data Type
  • integer
  • Default Value
  • MCRYPT_MODE_CBC

http.version

By default, Slim returns an HTTP/1.1 response to the client. Use this setting if you need to return an HTTP/1.0response. This is useful if you use PHPFog or an nginx server configuration where you communicate with backendproxies rather than directly with the HTTP client.

  1. <?php
  2. // During instantiation
  3. $app = new \Slim\Slim(array(
  4. 'http.version' => '1.1'
  5. ));
  6. // After instantiation
  7. $app->config('http.version', '1.1');
  • Data Type
  • string
  • Default Value
  • “1.1”