selfphp / console
Minimalistic PHP console component for simple command-line tools.
Installs: 12
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/selfphp/console
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