Skip to content

Instantly share code, notes, and snippets.

@that0n3guy
Created September 29, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save that0n3guy/2de87bad3a3ce272704aee114eb4695c to your computer and use it in GitHub Desktop.
Save that0n3guy/2de87bad3a3ce272704aee114eb4695c to your computer and use it in GitHub Desktop.
x2crm 5.0.4 main.php config file with rollbar, Dotenv, and composer autoload
<?php
// This file is to contain custom modifications to the $config array returned by
// protected/config/main.php via protected/config/web.php to construct the web
// application.
// this file is custom/protected/config/web.php
// this is for php composer integration
require_once dirname(__FILE__)."/../../../vendor/autoload.php";
// Use this to automagically load our .env file into the env for development environments
if (file_exists(dirname(__FILE__)."/../../../.env")) {
$dotenv = new Dotenv\Dotenv(dirname(__FILE__)."/../../../");
$dotenv->load();
}
// on production, staging, dev environments
$host = getenv ( 'MYSQL_HOST' );
$user = getenv ( 'MYSQL_USER' );
$pass = getenv ( 'MYSQL_PASSWORD' );
$dbname = getenv ( 'MYSQL_DBNAME' );
$config['components']['db']['connectionString'] = "mysql:host=$host;dbname=$dbname";
$config['components']['db']['username'] = $user;
$config['components']['db']['password'] = $pass;
$config['params']['adminEmail'] = $email; // I don't remember if this is needed or if this is some of our custom stuff.
//
//
// we use rollbar.com for errors on production
// Everything below this point is for rollbar.
//
$config['preload'] = array('log', 'rollbar');
$config['components']['rollbar'] = array(
'class' => 'webroot.vendor.baibaratsky.yii-rollbar.RollbarComponent', // adjust path if needed
'accessToken' => 'toeknGoesHere',
'environment'=> (isset($_SERVER['HTTP_HOST']) ? "" : "cliz-"). getenv ( 'ocaservertype' ), //ocaservertype is so we can identify the differences between environments in rollbar
'branch' => 'testing',
);
$config['components']['errorHandler'] = array(
'class' => 'webroot.vendor.baibaratsky.yii-rollbar.RollbarErrorHandler',
// ...
);
$config['components']['log']['routes'] =array(
array(
'class' => 'webroot.vendor.baibaratsky.yii-rollbar.RollbarLogRoute',
'levels' => 'error, warning',
// You may specify the name of the Rollbar Yii Component ('rollbar' by default)
'rollbarComponentName' => 'rollbar',
),
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment