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.
Full Changelog: https://github.com/mnapoli/silly/compare/1.9.1...1.10.0
Full Changelog: https://github.com/mnapoli/silly/compare/1.9.0...1.9.1
Full Changelog: https://github.com/mnapoli/silly/compare/1.8.3...1.9.0
Full Changelog: https://github.com/mnapoli/silly/compare/1.8.2...1.8.3
Full Changelog: https://github.com/mnapoli/silly/compare/1.8.1...1.8.2
Full Changelog: https://github.com/mnapoli/silly/compare/1.8.0...1.8.1
Full Changelog: https://github.com/mnapoli/silly/compare/1.7.3...1.8.0
Compatibility with Symfony 5.
Lighter package when installed via Composer
#33 & #39 Support PSR-11
#39 Support PHP 7.0 and up only
#36 & #38 Allow to inject the SymfonyStyle object introduced in Symfony 2.8
use \Symfony\Component\Console\Style\SymfonyStyle;
...
$app->command('greet', function (SymfonyStyle $io) {
$io->write('hello');
});
- in them:$console->command('import [number-of-clicks]', function ($numberOfClicks = 1) {
var_dump($numberOfClicks); // prints 1
});
#27, #28, #29: Throw an explicit exception when commands are registered as static calls to non static method calls.
Wrong way:
$this->application->command('greet', ['MyClass', 'foo']);
class MyClass {
public function foo() { ... }
}
That will now correctly throw an exception.
This should be used instead:
$this->application->command('greet', [new MyClass(), 'foo']);
Or you can use dependency injection with an autowiring container (http://mnapoli.fr/silly/docs/dependency-injection.html), for example with PHP-DI: http://mnapoli.fr/silly/docs/dependency-injection.html That way you don't have to change your code.
This release contains improvements on command arguments and options, by @thecrypticace:
Allow options to have default values (#25, documentation)
$app->command('greet [--age=]', function ($age) {
// ...
})->defaults([
'age' => 25,
]);;
Default values can now be inferred from the callable's parameters (#25, documentation)
$app->command('greet [name] [--age=]', function ($name = 'John', $age = 25) {
// ...
});
Fixed: matching arguments and options containing hyphens (#26, documentation)
$app->command('run [--dry-run]', function ($dryRun) {
// ...
});
#23 and #24 Support defining command aliases
#20: compatibility with Symfony 3.x as well as 2.x.
#17 Run a sub-command easily with runCommand(), for example:
$app->command('init', function ($input, $output) {
$this->runCommand('db:drop --force', $output)
$this->runCommand('db:create', $output)
$this->runCommand('db:fixtures --verbose', $output)
});
Use the new php-di/invoker package, which removes a warning when installing Silly.
New documentation and website: http://mnapoli.fr/silly/
First stable release.
Changes since v0.2:
0.x versions do not keep backward compatibility.
--option=* (was previously [--option=]*--option=?) have been removed as they are completely buggy and unusable in Symfony…0.x versions do not keep backward compatibility.
How can I help you explore Laravel packages today?