Download the PHP package sentinel-service/laravel-remote-config without Composer
On this page you can find all versions of the php package sentinel-service/laravel-remote-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download sentinel-service/laravel-remote-config
More information about sentinel-service/laravel-remote-config
Files in sentinel-service/laravel-remote-config
Download sentinel-service/laravel-remote-config
More information about sentinel-service/laravel-remote-config
Files in sentinel-service/laravel-remote-config
Vendor sentinel-service
Package laravel-remote-config
Short Description Remote configuration management for Laravel applications
License MIT
Package laravel-remote-config
Short Description Remote configuration management for Laravel applications
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-remote-config
Laravel Remote Config
Laravel 远程配置管理包。此扩展包允许你从中央配置服务器存储和获取配置值,支持加密、缓存,并与 Laravel 的配置系统无缝集成。
功能特性
- 与 Laravel 配置系统无缝集成
- 支持配置值加密
- 自动缓存(可配置缓存时间)
- 请求失败重试机制
- 配置刷新命令行工具
- 本地配置值回退支持
- 符合 PSR-4 规范
- 支持路径映射配置
- 文件缓存系统
环境要求
- PHP ^7.4|^8.0
- Laravel ^8.0|^9.0|^10.0|^11.0
- Guzzle ^7.0
安装
通过 composer 安装扩展包:
配置
发布配置文件:
这将在 config 目录下创建 remote.php 配置文件。在 .env 文件中添加以下环境变量:
配置选项
使用方法
基本用法
安装后,你可以直接使用 Laravel 的 config() 辅助函数。扩展包会自动尝试从远程服务器获取配置值:
路径映射
你可以在配置文件中定义路径映射,将远程配置值映射到指定的配置路径:
这样,当访问 config('aws.key')
时,扩展包会:
- 从远程服务器获取配置
- 根据映射关系更新配置值
- 缓存结果
刷新配置
你可以使用提供的 Artisan 命令刷新远程配置:
缓存机制
扩展包使用文件缓存系统存储远程配置:
- 缓存文件位置:
storage/framework/cache/data/remote-config.json
- 缓存时间可通过
REMOTE_CONFIG_CACHE_TTL
环境变量配置 - 支持自动过期和刷新
错误处理
扩展包会优雅地处理各种错误情况:
- 远程服务器不可用时使用本地配置
- 缓存无效时自动刷新
- 配置映射错误时保持原值
安全性
在存储敏感信息(如 API 密钥)时,请确保:
- 使用 HTTPS 协议访问远程配置 API
- 妥善保管 REMOTE_CONFIG_SECRET
- 使用环境变量存储敏感信息
- 定期更换密钥和令牌
架构说明
扩展包采用模块化设计:
Repository/RemoteConfig
: 核心配置仓库,继承自 Laravel 的 RepositoryServices/RemoteConfigService
: 处理远程配置获取Services/ConfigCacheService
: 管理配置缓存Services/PathConfigMapper
: 处理配置路径映射Commands/RefreshConfigCommand
: 提供配置刷新命令Contracts
: 定义接口规范
这种设计确保了:
- 高内聚低耦合
- 易于测试和维护
- 符合 SOLID 原则
- 灵活的扩展性
All versions of laravel-remote-config with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
guzzlehttp/guzzle Version ^7.0
The package sentinel-service/laravel-remote-config contains the following files
Loading the files please wait ....