模块的Laravel配置文件

模块的Laravel配置文件,laravel,laravel-5,Laravel,Laravel 5,我需要获取模块配置中的文件密钥。我使用包创建了User模块。这是registerConfig功能 protected function registerConfig() { $this->publishes([ __DIR__.'/../Config/config.php' => config_path('user.php'), ], 'config'); $this->mergeConfigFrom( __DIR__.'

我需要获取模块配置中的文件密钥。我使用包创建了
User
模块。这是
registerConfig
功能

protected function registerConfig()
{
    $this->publishes([
        __DIR__.'/../Config/config.php' => config_path('user.php'),
    ], 'config');
    $this->mergeConfigFrom(
        __DIR__.'/../Config/config.php', 'user'
    );
}
我创建了一个名为
menu.php
的文件,该文件返回一个带有键
items
的数组,然后尝试了以下操作

dd(config('user::config.name'))
dd(config('user::menu.items'))
它们都返回null。我还尝试了
UserServiceProvider
php artisan供应商发布
,但它仍然返回null。我怎么还钥匙

更新


若我只是这样做:
config()
我会得到一个完整的配置数组数组,并且可以在那个里看到我的包配置文件。但是
菜单
配置文件不在serviceProvider的register方法中

    $this->mergeConfigFrom(
        __DIR__ . '/../config/master.php',
        'master'
    );

    // Merge configs
    $this->mergeConfigFrom(
        __DIR__ . '/../config/slave.php',
        'slave'
    );
在config文件夹中创建两个文件 slave.php

    <?php
return [
    'menu' => [
        'OP1',
        'OP2',
        'OP3',
        'OP4',
    ]
];

])

config(“user.name”)
。您需要使用服务提供商的publishes in boot方法和mergeConfigFrom in register方法。@Bugfixer
config(“config.name”)
config(“user.name”)
都返回结果。但我无法获取单独文件中的菜单键。菜单的配置位于
menu.php
而不是
config.php
如何在服务提供者中调用menu.php。需要在服务提供程序中调用它。@Bugfixer
registerConfig
有问题。我没叫它进去!我该怎么做?
config('menu.items')
检查这是否有效?并检查menu.php和config.php是否在同一文件夹中。欢迎使用StackOverflow。请详细说明此配置的作用以及它如何帮助解决原始问题。只有代码的答案在StackOverflow中不被认为是高质量的。谢谢
array:4 [▼
  0 => "OP1"
  1 => "OP2"
  2 => "OP3"
  3 => "OP4"
]
return [
'name' => 'Blog',
'en_name'=>'Blog',
'icon'=>'comment',
'color1'=>'EF6F6C',
'color2'=>'EF6F6C',
'route'=>'blog',
'disable' => false,

'subs'=>[
    ['name'=>'All Posts','route'=>'blog/list'],
    ['name'=>'All Categories','route'=>'category/list']
]