简体   繁体   English

Laravel和Github-工作流程和问题

[英]Laravel and Github - Workflow and Problems

I have a Laravel project right now and I'm using Github for my project. 我现在有一个Laravel项目,而我的项目正在使用Github。

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. 我将所有文件放在一个文件夹/ dev中,我正在使用Sublime Text 2和官方的Github Client。 When I switch branches, I see that in ST2 in the status bar, that's fine. 当我切换分支时,我在状态栏中的ST2中看到了,这很好。
I put sftp-config.json in my gitignore BUT I have different FTP data for master and develop. 我将sftp-config.json放到了gitignore中,但是我有不同的FTP数据供主和开发使用。 I always have to edit the data in ST2 tu upload correctly onto my FTP to test my changes. 我始终必须将ST2 tu中的数据正确地上传到我的FTP上,以测试更改。 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 . route.php的问题相同,我需要为我的设备禁用route.php中的SSL,因为我没有通配符证书,并且我的dev分支机构/ ftp运行在dev.domain.tld和我的主要站点www.domain上.tld。

I created a environment for my Laravel configs, one main config and "development" config. 我为Laravel配置,一个主要配置和“开发”配置创建了一个环境。
Is it possible to use Config::get('app.ssl') in my routes.php in my filter? 是否可以在我的过滤器Config::get('app.ssl')使用Config::get('app.ssl') 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. Laravel开箱即用地支持环境配置。 You can find pretty much everything you need in the official docs . 您可以在官方文档中找到几乎所需的所有内容。 However here's an example: 但是,这是一个示例:

app/config/app.php - "main config" app / config / app.php- “主配置”

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

app/config/ local /app.php - config for the environment local (you can call it whatever you want) 应用程序/配置/ 本地 /app.php -配置对环境的local (你可以叫它任何你想要的)

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. Laravel使用主机名来检测环境。 So you need to figure out how your machine(s) is called. 因此,您需要弄清楚如何调用您的计算机。 An easy way to do that is with the PHP function gethostname() 一个简单的方法是使用PHP函数gethostname()

In bootstrap/start.php you can define your environments: bootstrap / start.php中,您可以定义您的环境:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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