Environments

Multiple server environments supported!

Environments are defined in your /inc/settings.php. Tatanka will automatically determine what server environment its running on.

Detecting the Environment with $app->environment()

You can detect which server environment tatanka is currently running on using the $this->environment or $app->environment variables. For example:

<?php
if($this->environment == 'production') {   
  // Do something
} else {
	// Do something else...
}
?>

$this and $app are equal inside the scope of your app's child class. Inside layout files use $app.

Simple Environment Setup

Below is a simple, single-environment setup. Below is the /inc/settings.ignore.php file:

<?php	
/**
 * /inc/settings.ignore.php
 */
if (!defined('ENVIRONMENTS')) {
	define('ENVIRONMENTS',serialize(array(
		'production'	=> array(	
      'host'		=>'www.myapplication.com',
      'docroot'	=>'/var/www/html/myapplication',
      'dbhost'	=>'myapplication.asdf.rds.amazonaws.com:3306',
      'dbname'	=>'db-name',
      'dbuser'	=>'db-user',
      'dbpass'	=>'db-password')
			)
		)
	);
}
?>

Advanced Environment Setup

This is a more advanced multi-environment setup. Below is the /inc/settings.ignore.php file:

<?php	
/**
 * /inc/settings.ignore.php
 */
if (!defined('ENVIRONMENTS')) {
	define('ENVIRONMENTS',serialize(array(
    // Production
		'production'	=> array(	
      'host'		=>'www.myapplication.com',
      'docroot'	=>'/var/www/html/myapplication',
      'dbhost'	=>'myapplication.a-notreal-sdf.rds.amazonaws.com:3306',
      'dbname'	=>'db-name',
      'dbuser'	=>'db-user',
      'dbpass'	=>'db-password'),
    // Local Environment, e.g. MAMP
		'local'			=> array(	
      'host'		=>'www.localmyapplication.com',
      'docroot'	=>'/Users/Me/Documents/myapplication',
      'dbhost'	=>'myapplication.adf-notreal-g.rds.amazonaws.com:3306',
      'dbname'	=>'db-name',
      'dbuser'	=>'db-user',
      'dbpass'	=>'db-password'),
    // Staging Environment, e.g. Clone of Production
		'staging'		=> array(	
      'host'		=>'dev.myapplication.com',
      'docroot'	=>'/var/www/html/dev.myapplication',
      'dbhost'	=>'myapplication.a-notreal-dfg.rds.amazonaws.com:3306',
      'dbname'	=>'db-name',
      'dbuser'	=>'db-user',
      'dbpass'	=>'db-password')
			)
		)
	);
}
?>