Foundational PHP library providing Monolog-based logging helpers, JSON parsing, a Symfony Console command base class, and class-discovery utilities.

Maintainers

Package info

bitbucket.org/magmasoftwareengineering/base

Issues

pkg:composer/magmasoftwareengineering/base

Statistics

Installs: 9

Dependents: 1

Suggesters: 0

4.0.1 2026-05-19 16:39 UTC

This package is not auto-updated.

Last update: 2026-05-20 17:34:02 UTC


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/jsonlint for 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

Architecture

This library establishes the foundation for:

  1. Logging & Debug utilities - Used by all higher-level libraries
  2. Dependency Injection - Through PHP-DI integration
  3. CLI tooling - For command-line applications
  4. 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