1

I am working on a Laravel 4 project and I need to be able to switch between multiple configurations. So as far as I know Laravel enables me to configure envs based on URL like this in the start.php

$env = $app->detectEnvironment(array( 'local' => array('localhost'), 'stage' => array('project.stage.com'), 'prod' => array('project.production.com'), )); 

And each of this configs consists of separate database connections and other configuration files. What I want is on my local environment to be able to switch between local,stage and prod, so for example if I want to connect to the prod database from my local project to test something. As far as I can understand if I want to do this I need to manualy switch the database connection strings in the local configuration. Is there any other way for switching between configurations on local level ? Hope my question was clear.

1 Answer 1

2

You can pass a closure to the function to determine set the environment more dynamically. You can either replicate the logic laravel uses and only use the closure in combination with gethostname() or just comment the part out and add this for testing:

$app->detectEnvironment(function(){ return 'stage'; }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.