Product Decisions This Supports
-
Internal Developer Tools (DevTools) Acceleration:
- Build lightweight, reusable CLI tools for internal teams (e.g., database migrations, API testing, or deployment scripts) without reinventing the wheel.
- Reduce dependency on monolithic frameworks like Laravel Artisan for simple CLI needs, lowering cognitive load and startup time.
-
Roadmap: CLI-First Features:
- Enable "command-driven" workflows (e.g.,
php app.php migrate:fresh --seed) for Laravel-based products, aligning with Laravel’s ecosystem while keeping flexibility.
- Build vs. Buy: Avoid building a custom CLI layer when Silly provides 80% of the functionality with minimal overhead. Justify adoption by comparing it to Symfony Console directly (no abstraction tax).
-
Use Cases:
- Developer Experience (DX): Ship CLI tools for end-users (e.g.,
php app.php setup --interactive) to reduce onboarding friction.
- Automation: Replace Bash/Python scripts with PHP-based CLI tools for consistency in polyglot environments (e.g., Laravel + Node.js).
- Extensibility: Allow third-party developers to contribute commands to your product via a standardized interface (e.g., plugins for a SaaS product).
-
Dependency Injection (DI) Strategy:
- Standardize on PSR-11 containers (PHP-DI or Pimple) for CLI commands, enabling:
- Reusable services across CLI and web layers (e.g., shared
LoggerInterface).
- Testability by mocking dependencies in commands.
- Example: Use PHP-DI for new projects to leverage autowiring; Pimple for legacy Silex-based codebases.
-
Performance-Critical CLI Tools:
- Silly’s minimal footprint (~10KB) makes it ideal for high-frequency CLI tasks (e.g., real-time data processing scripts) where Symfony Console’s overhead is prohibitive.
When to Consider This Package
-
Look Elsewhere If:
- You need GUI integration: Silly is CLI-only; pair with Symfony UI or Laravel Nova for dashboards.
- Your commands require complex state management: Use Symfony Full Stack or Laravel for session/route-based workflows.
- You’re building a public-facing API: Silly is for CLI, not HTTP endpoints (use Laravel API resources instead).
- Your team lacks PHP CLI experience: Silly assumes familiarity with Symfony Console’s patterns (e.g.,
InputInterface).
- You need advanced async support: Silly is synchronous; use ReactPHP or Symfony Messenger for async tasks.
-
Adopt Silly When:
- Your CLI tools are >70% boilerplate (e.g., argument parsing, help generation).
- You’re already using Symfony Console elsewhere in the codebase (avoid duplication).
- Your commands share dependencies with web services (leverage DI containers).
- You want zero-configuration for simple commands (e.g.,
php app.php greet --name=Alice).
- Your team prefers PHP over Bash/Python for maintainability (e.g., type safety, IDE support).
How to Pitch It (Stakeholders)
For Executives:
*"Silly lets us ship CLI tools faster and with fewer bugs. For example, we can replace our custom Bash scripts for database migrations with a PHP-based command like php app.php migrate:reset --force, which is:
- 10x more maintainable (type hints, autocompletion, tests).
- Reusable across our Laravel and non-Laravel services.
- Future-proof—it integrates with our existing Symfony-based tools.
This reduces dev time by 30% for internal tools and enables us to offer CLI-driven features to customers (e.g., php app.php setup) without hiring specialized CLI engineers. The MIT license and Tidelift support also mitigate risk."*
For Engineering:
*"Silly is a thin wrapper around Symfony Console that adds:
- Dependency Injection: Use PHP-DI or Pimple to inject services into commands (e.g.,
LoggerInterface $logger).
- Flexible Callables: Define commands as closures, classes, or static methods—no forced architecture.
- Laravel Compatibility: Works alongside Artisan; can even extend Laravel’s CLI ecosystem.
Example: Replace this Bash script:
#!/bin/bash
NAME=$1
if [ -z "$NAME" ]; then echo "Hello"; else echo "Hello, $NAME"; fi
With this PHP command (10 lines, type-safe):
$app->command('greet [name]', function (string $name = 'World') {
echo "Hello, {$name}!";
});
Why not Symfony Console directly?
- Silly’s
Application class handles edge cases (e.g., command defaults, hyphen-to-camelCase conversion) out of the box.
- Built-in DI support saves us from writing custom resolvers.
Migration Path:
- Start with simple closures for quick wins.
- Gradually adopt PHP-DI for complex commands to share services with web layers.
- Replace 1–2 Bash scripts/month with Silly to prove ROI."*
For Developers:
*"Silly gives you:
- Symfony Console’s power (help menus, argument parsing) with less boilerplate.
- DI out of the box: No more manually instantiating services in commands.
- Laravel-friendly: Works in Laravel projects without conflicts.
Try This:
// Install
composer require mnapoli/silly
// Create a command
$app = new \Silly\Application();
$app->command('deploy [--dry-run]', function (bool $dryRun) {
if ($dryRun) {
echo "Would deploy...";
} else {
echo "Deploying!";
}
});
$app->run();
Run with:
php deploy.php deploy --dry-run
Pro Tip: Use PHP-DI for autowiring:
$app = new \Silly\Application\PhpDi();
$app->command('log [message]', function (LoggerInterface $logger, string $message) {
$logger->info($message);
});
```"*