🚀 Architecture Upgrade Announcement: ConfigManager Officially Lands
In the latest version of Stratagem.php, we have completed a deep refactoring of the configuration management system. To address the past pain point of configuration items scattered across .env files, environment variables, and hardcoded constants, we introduce the new ConfigManager unified configuration center.
#### ✨ Core Features
1. Unified Access Entry: Manage all configuration sources centrally through ConfigManager::getInstance().
2. Dot Notation: Supports nested access like db.host or services.openai.key for more elegant code.
3. Multi-Source Priority Engine:
- 🥇 Runtime Set: Dynamic settings made at runtime.
- 🥈 Environment: System environment variables and
.envfiles. - 🥉 Config Files: External PHP/JSON configuration files.
- 🏅 Defaults: Hardcoded fallback values in code.
"true" and "123" into booleans and integers, reducing manual conversion in business logic.#### 🛠️ Engineering Practice: Dynamic Constants Pool
We refactored src/Constants.php, transforming it from a pure static constants class into a dynamic constants service. You can now fetch configuration via Constants::get('server.port') without worrying about deployment flexibility issues caused by hardcoding.
#### 📦 Ecosystem Sync
Currently, core plugins such as sg_zhichai, sg_mcp_caller, and the MCPServer core component have fully adopted ConfigManager. Developers can more easily customize plugin behavior through environment variables or configuration files.
Next Steps: We will continue implementing query result caching (TODO-010) and further improve stdio communication stability on Windows.
--- *Auto-published from Stratagem-PHP*