Download the PHP package sanmai/console without Composer
On this page you can find all versions of the php package sanmai/console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sanmai/console
More information about sanmai/console
Files in sanmai/console
Package console
Short Description Ready-made extensible console application using Symfony Console component
License Apache-2.0
Informations about the package console
sanmai/console
Zero-configuration console executable that auto-discovers your Symfony Console commands.
Installation
For Auto-Discovery
If you want commands to be discovered automatically:
Auto-discovery uses Composer's classmap, which requires an optimized autoloader.
For PSR-4 Projects
If you prefer explicit command registration without optimization, configure a custom provider.
Quick Start
-
Create a Symfony Console command:
-
Update the autoloader:
- Run your command:
That's it! No configuration files, no manual command registration.
How It Works
This library provides a ready-made vendor/bin/console executable that automatically discovers all Symfony Console commands in your project:
-
Auto-discovery (requires an optimized autoloader):
- Scans Composer's classmap for classes extending
Commandwith names ending inCommand - Finds
CommandProviderInterfaceimplementations with names ending inCommandProvider - Filters out vendor files
- Skips classes that throw exceptions during instantiation
- Scans Composer's classmap for classes extending
- Custom provider (optional, no optimization needed):
- Loads the provider specified in
extra.console.provider - Provider returns command instances via its iterator
- Works alongside auto-discovery
- Loads the provider specified in
The Problem It Solves
I found myself writing the same console bootstrap script over and over. Even with Symfony's command discovery features, you still had to write a lot of boilerplate code.
With sanmai/console, you get a ready-made vendor/bin/console executable installed via Composer. No files to create, no permissions to set - just install the package and vendor/bin/console is ready to use. It even works in legacy projects that never had Symfony Console commands before.
Configuration
Bootstrap Scripts
Configure a custom bootstrap script in your composer.json:
Or use Composer commands:
The bootstrap script runs after Composer's autoloader is initialized. Including vendor/autoload.php again is safe - the library handles this gracefully.
Example bootstrap script:
Custom Provider Configuration
In addition to auto-discovery, you can specify a custom command provider:
Or using Composer command:
The custom provider:
- Works alongside auto-discovery (doesn't replace it)
- Doesn't need the
CommandProvidersuffix - Must implement
CommandProviderInterface - Must have a no-argument constructor
An optimized autoloader is not required to use the custom provider.
Commands with Dependencies
For commands that require constructor dependencies, implement the CommandProviderInterface:
CommandProviderInterface implementations must have no required arguments in their constructor as they are instantiated automatically.
Troubleshooting
Commands not showing up?
- Run
composer dump-autoload --optimize(add--devif your commands are in autoload-dev) - Verify your command class names end with
Command(e.g.,HelloCommand,MigrateCommand) - Check that commands extend
Symfony\Component\Console\Command\Command - Commands in
vendor/are ignored by default - Command providers must have class names ending with
CommandProvider
Testing
All versions of console with dependencies
sanmai/later Version ^0.1.7 || ^0.2
sanmai/pipeline Version ^6.17 || ^7.0
sanmai/version-info Version ^0.2 || ^0.3
symfony/console Version ^6.0 || ^7.0