Nyxynyx
Nyxynyx

Reputation: 63667

Variable value changes depending on domain using Laravel 4

In Laravel 4, how can we have

$pathToFile = '/var/www/awesome'
$mysqlServer = '111.111.111.0'

when domain of the site is www.mysite.com, and

$pathToFile = '/var/www/hackish'
$mysqlServer = '111.111.111.1'

when domain of the site is dev.mysite.com?

Upvotes: 0

Views: 77

Answers (1)

rmobis
rmobis

Reputation: 27002

Create a different environment for each domain, under bootstrap/start.php, and add specific file for it, under app/start folder. In your example, you could have:

bootstrap/start.php

// ...
$env = $app->detectEnvironment(array(
    'production'  => array('www.mysite.com'),
    'development' => array('dev.mysite.com'),
));

app/start/production.php

$pathToFile = '/var/www/awesome';
$mysqlServer= '111.111.111.0';

app/start/development.php

$pathToFile = '/var/www/hackish';
$mysqlServer= '111.111.111.1';

You should not though, that if you're working with the default configuration files, the same is valid for them. You can read more on the documentation.

Upvotes: 2

Related Questions