简体   繁体   中英

Laravel and Github - Workflow and Problems

I have a Laravel project right now and I'm using Github for my project.

I have two branches, master and develop.
The problem right now is,...

I have all the files in one folder /dev I'm using Sublime Text 2 and the official Github Client. When I switch branches, I see that in ST2 in the status bar, that's fine.
I put sftp-config.json in my gitignore BUT I have different FTP data for master and develop. I always have to edit the data in ST2 tu upload correctly onto my FTP to test my changes. Sometimes I even forget that, and accidentally upload develop to my master/live page.
Same problem for the routes.php, I need to disable SSL in my routes.php for the DEV because I do not have a wildcard certificate and my dev branches/ftp runs on dev.domain.tld and my main site at www.domain.tld .

I created a environment for my Laravel configs, one main config and "development" config.
Is it possible to use Config::get('app.ssl') in my routes.php in my filter? Like that:

Route::group(['before' => ['csrf',Config::get('app.ssl')]], function () {
    Route::get('page', array('as' => 'page','uses' => 'PageController@getIndex'));
});

?

My workflow right now is very annoying and confusing sometimes. I always have to check that I do not upload stuff on my live server or changes the master files.
Any suggestions are highly appreciated!

Of course! Laravel supports environmental configuration out of the box. You can find pretty much everything you need in the official docs . However here's an example:

app/config/app.php - "main config"

array(
    // other config entries
    'ssl' => true
)

app/config/ local /app.php - config for the environment local (you can call it whatever you want)

array(
    'ssl' => false // here we override the value from our main config
)

Now the last thing we have to do is make sure our environments get detected correctly.
Laravel uses the host name to detect an environment. So you need to figure out how your machine(s) is called. An easy way to do that is with the PHP function gethostname()

In bootstrap/start.php you can define your environments:

$env = $app->detectEnvironment(array(
    'local' => array('your-machine-name'),
    'other-environment' => array('other-machine-name')
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM