magmasoftwareengineering/base
Composer 安装命令:
composer require magmasoftwareengineering/base
包简介
Foundational PHP library providing Monolog-based logging helpers, JSON parsing, a Symfony Console command base class, and class-discovery utilities.
关键字:
README 文档
README
Version: 3.x | PHP: >=8.3 | License: MIT
Overview
The Base Library (magmasoftwareengineering/base) provides foundational utilities and abstractions for Magma Software Engineering projects. It includes logging, JSON parsing, command handling, and utility classes that serve as a foundation for more specialized libraries.
This is the lowest-level library in the Magma Software Engineering library hierarchy.
Key Features
Logging & Debugging
- Logger utility wrapper around Monolog for consistent logging across applications
- LoggableTrait / LoggableInterface - Add logging capabilities to any class
- LoggerChannelAwareTrait / LoggerChannelAwareInterface - Manage named logger channels
- DebuggableTrait / DebuggableInterface - Enable debug mode for classes
JSON Processing
- JsonParserTrait / JsonParserInterface - Standardized JSON parsing and validation
- Integration with
seld/jsonlintfor JSON validation
CLI Commands
- AbstractCommand - Base class for Symfony Console commands
- Built-in exception handling and logging
Utilities
- ClassFinder - Dynamic class discovery and instantiation
- Logger - Centralized logging configuration with channel support
Dependencies
monolog/monolog: ^3.7 (Logging framework)
php-di/php-di: ^7.0 (Dependency injection)
predis/predis: ^2.2 (Redis client)
psr/log: ^3.0 (PSR-3 logging interface)
seld/jsonlint: ^1.10 (JSON validation)
symfony/console: ^7.1 (CLI framework)
Installation
composer require magmasoftwareengineering/base:^3.0
Usage Examples
Logging
use MagmaSoftwareEngineering\Base\Utility\Logger;
$logger = new Logger();
$logger->info('Application started');
Adding Logging to Your Class
use MagmaSoftwareEngineering\Base\Interfaces\LoggableInterface;
use MagmaSoftwareEngineering\Base\Traits\LoggableTrait;
class MyService implements LoggableInterface {
use LoggableTrait;
public function doSomething() {
$this->log('Doing something important');
}
}
JSON Parsing
use MagmaSoftwareEngineering\Base\Interfaces\JsonParserInterface;
use MagmaSoftwareEngineering\Base\Traits\JsonParserTrait;
class DataProcessor implements JsonParserInterface {
use JsonParserTrait;
public function process($json) {
$data = $this->parseJson($json);
// Process validated JSON data
}
}
Next Steps
- Looking to add Doctrine ORM support? → Doctrine Base Library
- Ready to build Slim 4 applications? → Slim Base Library
Architecture
This library establishes the foundation for:
- Logging & Debug utilities - Used by all higher-level libraries
- Dependency Injection - Through PHP-DI integration
- CLI tooling - For command-line applications
- Data validation - JSON parsing and validation
The library is intentionally minimal to avoid unnecessary dependencies in projects that don't need the full stack.
Support & Contributing
For issues or contributions, please contact the maintainer:
- Jeremy Coates - hello@phpcodemonkey.me.uk
License
MIT License - See LICENSE file for details
统计信息
- 总下载量: 111
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-20