-
Notifications
You must be signed in to change notification settings - Fork 1
/
BaseServiceProvider.php
55 lines (47 loc) · 1.51 KB
/
BaseServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Created by PhpStorm.
* User: Icyboy <[email protected]>
* Date: 2016/5/19
* Time: 14:07
*/
namespace Icyboy\Core;
use Illuminate\Support\ServiceProvider;
use Monolog;
class BaseServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$app = $this->app;
$errorCodeConfigPath = __DIR__ . '/config/error_code.php';
$logConfigPath = __DIR__ . '/config/log.php';
//避免array_merge数字索引被打乱
$error_local_config = $this->app['config']->get('error_code', []);
$app['config']->set('error_code', array_replace(require $errorCodeConfigPath, $error_local_config));
$this->mergeConfigFrom($logConfigPath, 'log');
$app->configureMonologUsing(function (Monolog\Logger $monoLog) use ($app) {
$configureLogging = new Log\ConfigureLogging();
return $configureLogging->configureHandlers($app, $monoLog);
});
//加载RequestId Middleware
$app->middleware([
Middleware\RequestIdMiddleware::class
]);
}
public function boot()
{
// 内部编码
if ( function_exists('mb_internal_encoding') ) {
mb_internal_encoding(env('ENCODING','utf-8'));
}
// 正则用编码
if ( function_exists('mb_regex_encoding') ) {
mb_regex_encoding(env('ENCODING','utf-8'));
}
}
}