- What is pmjones/auto-shell and what does it do?
- AutoShell is a zero-dependency CLI router that maps a command name from argv to a PHP command class in a configured namespace, reflects on that class's main method to bind arguments and options, and returns an Exec object describing the invocation. Think of it as the router layer: Console passes argv to Shell, Shell returns Exec, and you invoke the Command. It is intended for standalone PHP CLIs rather than framework application commands.
- How do I install and set up AutoShell in a PHP project?
- Install it with composer require pmjones/auto-shell, then create a bin/console.php bootstrap that requires vendor/autoload.php and builds a Console with the command namespace, directory, and optional help text. That script passes $_SERVER['argv'] to the Console and exits with the returned code. Command classes are discovered by PSR-4 convention once placed in the configured namespace and directory, so there is no registration step.
- Does AutoShell work with Laravel Artisan?
- Not really. Laravel's console layer is built on Symfony Console and Artisan, and AutoShell would create a parallel command dispatcher and break conventional php artisan discoverability. AutoShell aligns with the PDS and Paul M. Jones ecosystem, not Symfony Console or Artisan. Use it for standalone bin scripts, cron or queue workers, and ops tooling outside Laravel application commands.
- Which PHP versions does AutoShell support?
- AutoShell requires PHP 8.1 or later because it uses PHP 8 attributes and readonly features. Check your build and runtime images before adopting it. If any part of your estate runs older PHP, it will not fit without changes.
- How do I define command arguments and options in AutoShell?
- Options and help are declared with PHP 8 attributes such as #[Option] and #[Help] on the command class and its main method. Method parameters may be scalar values like int, float, string, and bool, or arrays, and reflection binds argv values to them. There is no config file, service provider, or publishing step.
- Can I use a PSR-11 container for dependency injection with AutoShell?
- Yes, you can wire an optional PSR-11-backed factory to build command classes with dependency injection. That keeps commands container-aware without AutoShell taking a hard dependency on a container. Without a factory, command classes are instantiated by convention.
- Is AutoShell a good alternative to Symfony Console or Laravel Zero?
- Only for narrow cases. AutoShell is good for simple standalone CLIs, scripts, and operational tooling where Artisan or Symfony Console is overkill. It is not a replacement for Laravel Zero or Symfony Console when you need rich terminal UX, subcommand trees, plugins, or event wiring. Growth beyond simple dispatch is a signal to move to one of those ecosystems.
- Does AutoShell support subcommands, progress bars, or interactive prompts?
- No. AutoShell deliberately does not build in verbosity levels, progress bars, interactive prompts, signal handling, subcommand trees, or plugins. Output is plain text through injectable stdout and stderr callables, which works well for CI and pipe-friendly tools. Rich terminal UX is outside its scope.
- Is AutoShell production-ready and well maintained?
- It is technically low-risk in size and dependencies: no runtime dependencies, MIT license, tiny surface area, and a maintainer with a long track record in PHP CLI tooling. The risks are a single maintainer, zero declared dependents, and limited production evidence. Plan to vendor or fork if upstream slows, which the MIT license permits.
- How does AutoShell map command names to classes and handle errors?
- AutoShell maps the command name from argv to a class in the configured namespace and directory, reflects on the main method, and returns an Exec describing the class plus bound options and arguments. Misconfiguration such as a wrong namespace, directory, or main method name is the main failure mode, so verify PSR-4 autoloading and naming conventions. There is no built-in verbosity or interactive handling, so handle errors and output inside your command code.