mnapoli/silly
Silly is a lightweight CLI micro-framework built on Symfony Console. Define commands with simple signatures and PHP callables, get options/arguments parsing, helpers, and DI integration (PHP-DI or Pimple) while staying compatible with Symfony Console apps.
Console component, making it a natural fit for Laravel-based CLI tools (e.g., Artisan commands, migrations, or custom CLI utilities). Laravel already leverages Symfony Console under the hood, so Silly integrates seamlessly without architectural friction.Illuminate\Container), enabling consistent DI patterns across CLI and web layers. This reduces context-switching for developers familiar with Laravel’s service container.Illuminate\Console\Application (which itself extends Symfony’s Application). Example:
use Silly\Application;
use Illuminate\Foundation\Application as LaravelApp;
$laravelApp = new LaravelApp();
$sillyApp = new Application($laravelApp->make('command.helper'));
$sillyApp->command('custom:task', fn() => '...');
deploy:database command could inject DB, Storage, and Logger services from Laravel’s container.injectByTypeHint) may conflict with Laravel’s autowiring or binding conventions. Example: A Silly command expecting a LoggerInterface might resolve to Laravel’s Monolog instance, but custom bindings could cause ambiguity.silly.logger).php artisan silly:generate:docs) but less critical for core Laravel functionality.OutputInterface) integrate with Laravel’s logging (Log::error)? Define a consistent error format (e.g., JSON for APIs, colored text for TTY).Illuminate\Console\Application with Silly\Application. Example:
// app/Console/Kernel.php
protected $commands = [
Commands\SillyDeployCommand::class,
];
// Commands/SillyDeployCommand.php
use Silly\Application;
use Symfony\Component\Console\Input\InputInterface;
class SillyDeployCommand extends Command {
protected function handle(InputInterface $input, OutputInterface $output) {
$app = new Application();
$app->command('deploy', fn() => $this->deployLogic($output));
$app->run();
}
}
boot() method to lazy-load CLI tools.[argument] syntax.global vars with DI (e.g., inject Config, Filesystem).SymfonyStyle for consistent output (colors, progress bars).| Phase | Action | Tools/Examples |
|---|---|---|
| Assessment | Audit existing CLI tools for reusability and DI dependencies. | php artisan list, grep -r "exec(" |
| Pilot | Replace 1–2 non-critical commands with Silly prototypes. | php artisan make:silly-command |
| Integration | Extend Laravel’s container to support Silly’s DI (e.g., bind Silly\Application). |
app/Providers/SillyServiceProvider.php |
| Adoption | Migrate high-impact scripts (e.g., deploy tools) last. | CI/CD pipelines with Silly commands. |
InputInterface, OutputInterface, and Command classes. Existing Laravel CLI code using these will work unchanged.ArtisanStarting) by injecting the Illuminate\Events\Dispatcher.Gate or Policy classes in Silly commands via DI.php artisan silly:generate:api-docs).migrate into subcommands).$app->command('migrate:fresh', fn() => $this->call('migrate:reset'));
$app->command('migrate:seed', fn() => $this->call('db:seed'));
robo/robo to scaffold Silly commands from existing scripts.Command class definitions for simple tasks.createMock() or Laravel’s MockApplication.tinker and ide-helper may not fully support Silly’s DI features. Mitigation: Use php-di/php-di for advanced DI debugging.How can I help you explore Laravel packages today?