- Can I use Silly alongside Laravel’s Artisan without conflicts?
- Yes, Silly is designed to coexist with Artisan. Use Silly for project-specific CLI tools (e.g., `php cli:generate-report`) while keeping Artisan for Laravel-centric tasks like migrations or routes. Both share Symfony Console under the hood, so input/output handling remains consistent.
- How do I install Silly in a Laravel project?
- Run `composer require mnapoli/silly`—no Laravel-specific dependencies are required. Silly integrates seamlessly with Symfony Console, which Laravel already uses for Artisan, so no additional setup is needed beyond defining your commands.
- Does Silly support Laravel’s service container (Illuminate/Container) for dependency injection?
- Silly supports PSR-11 containers like PHP-DI or Pimple, but you can bridge Laravel’s container using adapters (e.g., `php-di/laravel-bridge`). For commands needing Laravel services (e.g., DB, Auth), resolve them via Silly’s container or pass them explicitly.
- What Laravel versions does Silly officially support?
- Silly has no Laravel-specific dependencies, so it works with any Laravel 5.5+ version (where Symfony Console is used). Test compatibility by checking if your Laravel version aligns with Silly’s Symfony Console dependency (e.g., Symfony 5.4+).
- How do I test Silly commands in a Laravel test suite?
- Test Silly commands in isolation using PHPUnit’s `Process` class to simulate CLI execution. For Laravel-specific commands, mock dependencies via Silly’s DI container (PHP-DI/Pimple) or Laravel’s container. Avoid coupling tests to Artisan’s kernel.
- Can I use Silly for background jobs instead of Laravel Queues?
- Yes, Silly is lightweight enough for background tasks. Define a command (e.g., `php worker:process`) and schedule it via Laravel’s `schedule:run` or a cron job. For complex jobs, use Silly’s DI to inject Laravel services like the queue manager.
- What’s the performance difference between Silly and raw Symfony Console?
- Silly adds minimal overhead—it’s essentially a thin wrapper around Symfony Console with DI and helper methods. Benchmark against raw Symfony Console if performance is critical, but Silly’s abstractions (e.g., command callables) often improve developer velocity.
- How do I handle errors in Silly commands (e.g., logging to Laravel’s log channel)?
- Silly commands can log to Laravel’s channels by injecting the `Log` facade or using Silly’s `OutputInterface` for console output. For structured logging, pass Laravel’s `Log` service via Silly’s DI container or catch exceptions and log them manually.
- Are there alternatives to Silly for Laravel CLI tools?
- For Laravel-specific CLI tools, Artisan is the default choice. For standalone or non-Laravel projects, alternatives include raw Symfony Console, `league/CLImate`, or `symfony/console` directly. Silly stands out for its DI integration and simplicity without Laravel bloat.
- Can I deploy Silly CLI tools separately from Laravel (e.g., as standalone scripts)?
- Absolutely. Silly commands are self-contained and can be deployed independently (e.g., via `bin/console` or custom scripts). Use Composer’s `bin` directory or a wrapper script to ensure dependencies are available without requiring the full Laravel environment.