PHP code example of sentinel-service / laravel-remote-config
1. Go to this page and download the library: Download sentinel-service/laravel-remote-config library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sentinel-service / laravel-remote-config example snippets
return [
// API 配置
'api' => [
'url' => env('REMOTE_CONFIG_API_URL'),
'secret' => env('REMOTE_CONFIG_SECRET'),
],
// 缓存设置
'cache' => [
'ttl' => env('REMOTE_CONFIG_CACHE_TTL', 3600) // 缓存时间(秒),默认1小时
],
// 需要从远程获取的配置路径
'paths' => [
'aws.key',
'services.r2'
],
// 路径到环境变量的映射
'path_env_mapping' => [
'aws.key' => [
'key' => 'AWS_ACCESS_KEY_ID',
'secret' => 'AWS_SECRET_ACCESS_KEY'
],
'services.r2' => [
'key' => 'R2_ACCESS_KEY_ID',
'secret' => 'R2_SECRET_ACCESS_KEY'
],
// 单个值的例子
'app.name' => [
'value' => 'APP_NAME'
],
]
];
// 优先从远程获取配置,如果失败则使用本地配置
$value = config('aws.key');
'path_env_mapping' => [
'aws.key' => [
'key' => 'AWS_ACCESS_KEY_ID',
'secret' => 'AWS_SECRET_ACCESS_KEY'
]
]
bash
php artisan vendor:publish --provider="SentinelService\RemoteConfig\RemoteConfigServiceProvider"
bash
php artisan remote-config:refresh