在Workbench软件包中添加Sentry 2配置 [英] Adding Sentry 2 config in Workbench Package
问题描述
我正在使用laravel 4.1,并在工作台中处理自己的软件包.我在包composer.json中添加了额外的仓库(哨兵2). Sentry正常工作,但是我无法通过从工作台/程序包/名称/src/config/packages/cartalyst/sentry/config.php加载配置文件来覆盖配置
I am using laravel 4.1 and working on my own package in workbench. I added extra repo (sentry 2) in my package composer.json. Sentry is working properly but I can't override config by loading config files from workbench/package/name/src/config/packages/cartalyst/sentry/config.php
我的服务提供商看起来像这样:
My service Provider looks like that:
public function boot()
{
// https://coderwall.com/p/svocrg
$this->package('package/name');
$config_path = __DIR__ . "/../../config/packages/cartalyst/sentry";
$this->app['config']->package('cartalyst/sentry', $config_path, 'cartalyst/sentry');
$this->app->register('Cartalyst\Sentry\SentryServiceProvider');
include __DIR__.'/../../routes.php';
}
public function register()
{
$this->app->booting(function()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Sentry', 'Cartalyst\Sentry\Facades\Laravel\Sentry');
});
}
当我覆盖config.php中的某些内容时(工作台/程序包/名称/src/config/packages/cartalyst/sentry/config.php),我仍然从vendor/cartalyst/sentry/src/config/config.php获取内容.如何在工作台软件包中正确加载配置
When I override something in config.php (workbench/package/name/src/config/packages/cartalyst/sentry/config.php) I still get things from vendor/cartalyst/sentry/src/config/config.php. How to properly load config in workbench package
推荐答案
我认为您不能这样做,因为正如Cartalyst哨兵官方网站哨兵是第三方"所解释的
I think you can't because as explained at official cartalyst sentry website "sentry is third party"
但是您仍然可以在工作台的composer文件中做一些技巧.
but you still can do some trick in your composer file in workbench.
在工作台中的composer.json中:
at your composer.json in workbench :
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize",
"php artisan app:sentry" /* add your own command which organize to create your own sentry configuration (remember mkdir cartalyst/sentry/config.php store to app/config/packages) */
],
// more
},
这意味着,在安装软件包时,将执行您自己的命令(例如php artisan app:sentry)
this mean, when your package in installing, your own command (e.g : php artisan app:sentry) will be executed
希望这对您有帮助...
hope this help you...
在您的作曲家脚本中添加键:
in your composer scripts key add :
"php artisan config:publish --package=cartalyst/sentry"
,然后在PackageServiceProvider的启动方法中, 设置您自己的配置. 例如:
and then, at boot method in your PackageServiceProvider, set your own configuration. for example :
public function boot()
{
// for change user sentry model
\Config::set('sentry::config.user.model', 'Vendor\Package\YourUserModel');
}
我认为这是最简单的方法. :)
I think this is more simplest way. :)
这篇关于在Workbench软件包中添加Sentry 2配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!