zenigata/utility

Maintainers

Package info

github.com/zenigataphp/utility

pkg:composer/zenigata/utility

Statistics

Installs: 17

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

0.2.0 2026-03-13 16:20 UTC

This package is auto-updated.

Last update: 2026-03-13 16:20:43 UTC


README

⚠️ This project is in an early development stage. Feedback and contributions are welcome!

Lightweight collection of PHP utility classes to simplify common development tasks.

The library provides small, focused helpers and traits that reduce boilerplate when working with PSR standards, configuration files, reflection, and more. Each component is designed to be framework-agnostic, minimal, and easy to integrate into any PHP project.

Requirements

Installation

composer require zenigata/utility

Overview

Awareness

Traits that provide awareness for common dependencies, allowing classes to receive services such as containers, factories, or debug state without requiring dependency injection.

Helper

Collection of small utilities that simplify common tasks such as configuration loading, caching interoperability, file generation, and more.

  • CacheHelper for interacting with both PSR-6 and PSR-16 caches with a unified API. It hides the differences between the two standards, so you can use the same methods regardless of the underlying cache implementation.
  • ConfigLoader for lazily loading PHP configuration files using generators, ensuring minimal memory usage when working with multiple config files.
  • ReflectionResolver for instantiating classes with empty constructors using PHP reflection, useful when no dependency injection container is available.
  • StubRenderer for generating files from stub templates with placeholder replacement and automatic directory creation.

Testing

Simple test doubles designed to simplify unit testing when full implementations are unnecessary.

  • FakeContainer: in-memory implementation of PSR-11 ContainerInterface, useful for testing container-aware classes and manually registering dependencies.
  • FakeLogger: lightweight PSR-3 logger that records log messages in memory, allowing tests to inspect and assert logged output.
  • FakeMiddleware: configurable PSR-15 middleware that can optionally return a predefined response or execute a callback during processing, making it easy to test middleware pipelines.
  • FakeRequestHandler: simple PSR-15 request handler returning a predefined response, with optional callback execution to observe request handling during tests.

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Keep the implementation minimal, focused, and well-documented, making sure to update tests accordingly.

See CONTRIBUTING for more information.

License

This library is licensed under the MIT license. See LICENSE for more information.