entropy / entropy
Entropy framework
Requires
- php: ^8.3
- ext-tokenizer: *
- webmozart/assert: ^2.1
Requires (Dev)
- phpecs/phpecs: ^2.3
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
- rector/jack: ^1.0
- rector/rector: ^2.4
- rector/swiss-knife: ^2.3
- shipmonk/composer-dependency-analyser: ^1.8
- symplify/easy-coding-standard: ^13.0
- symplify/phpstan-extensions: ^12.0
- symplify/phpstan-rules: ^14.9
- tomasvotruba/type-coverage: ^2.1
- tomasvotruba/unused-public: ^2.2
- tracy/tracy: ^2.11
This package is auto-updated.
Last update: 2026-05-03 20:46:23 UTC
README
A tiny framework with a dependency injection container and a console runner. No configuration, no YAML, no magic strings - just classes.
Install
composer require entropy/entropy
1. Dependency Injection
The container autowires services through reflection. Point it at a directory and every class in it becomes an available service.
use Entropy\Container\Container; $container = new Container(); $container->autodiscover(__DIR__ . '/src'); $someService = $container->make(SomeService::class);
Need a custom factory? Register it manually:
$container->service(PDO::class, function (Container $container): PDO { return new PDO('sqlite::memory:'); });
Need every implementation of an interface? Ask for the contract:
$listeners = $container->findByContract(EventListenerInterface::class);
The container detects circular dependencies and tells you exactly where the cycle is, e.g. A -> B -> C -> A.
2. Console
Implement CommandInterface and the command is wired up automatically:
use Entropy\Console\Contract\CommandInterface; use Entropy\Console\Enum\ExitCode; use Entropy\Console\Output\OutputPrinter; final readonly class HelloCommand implements CommandInterface { public function __construct( private OutputPrinter $outputPrinter ) { } public function getName(): string { return 'hello'; } public function getDescription(): string { return 'Say hello'; } /** * @param string[] $paths Paths to greet. * @param bool $loud Shout instead of speak. */ public function run(array $paths, bool $loud = false): int { $this->outputPrinter->green('Hello!'); return ExitCode::SUCCESS; } }
The run() method signature is the command definition. Argument types, default values, and docblocks become CLI arguments, options, and help text. No attributes to add, no input objects to wire.
Boot the application from your binary:
use Entropy\Console\ConsoleApplication; use Entropy\Container\Container; $container = new Container(); $container->autodiscover(__DIR__ . '/src'); $consoleApplication = $container->make(ConsoleApplication::class); exit($consoleApplication->run($argv));
That's it. Run it:
bin/console hello src/ --loud
Typo a command name and the fuzzy matcher will pick the closest one. Pass --help for global help, or command --help for command-level help built from your docblocks.
Happy coding!