selfphp / console
Minimalistic PHP console component for simple command-line tools.
v1.0.0
2025-06-11 13:40 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^10.0
README
🧩 A lightweight PHP console framework for simple CLI tools – with zero dependencies.
🚀 Features
- ✅ Register custom commands easily
- ✅ Automatic help command (
php bin/console help
) - ✅ Clean PSR-4 structure
- ✅ Works on Windows, Linux, macOS
- ✅ No Symfony or external dependencies
📦 Installation
composer require selfphp/console
🛠 Usage
Create an entry file (e.g. bin/console
):
#!/usr/bin/env php <?php require __DIR__ . '/../vendor/autoload.php'; use Selfphp\Console\ConsoleApp; use YourNamespace\Console\AuditCommand; use Selfphp\Console\Command\HelpCommand; $app = new ConsoleApp(); $app->register(new AuditCommand()); $app->register(new HelpCommand($app)); exit($app->run($argv));
Create a command:
namespace YourNamespace\Console; use Selfphp\Console\Contract\CommandInterface; class AuditCommand implements CommandInterface { public function getName(): string => 'audit'; public function getDescription(): string => 'Runs an audit'; public function run(array $args): int { echo "Audit running...\n"; return 0; } }
Run your CLI:
php bin/console audit
php bin/console help
🤝 Contributing
Feel free to submit issues, ideas or pull requests.
📄 License
MIT License © 2025 SELFPHP – Damir Enseleit