Releases: basuke/Clim
Support parameter binding
With parameter binding
, the parameters of task function are automatically pulled from container, options or arguments.
example:
$app->task(function(\PDO $db, array $args) {
// $db will be pulled from container
// equivalent to
// /** @var \PDO $db */
// $db = $this->db;
});
For $options and $arguments which is the parameters for task prior to 1.5.0, there must be a special rule for them.
$options
and$opts
are reserved argument forarray $options
$arguments
and$args
are reserved argument forarray $arguments
$context
are reserved argument forContext $context
- It's possible to specify those should be array or Hash or whatever classes accept array to its constructor. The default is
array
.
Define sub command alias on dispatch()
$app = new App();
$app->dispatch('{COMMAND}', [
'hi|hello' => function (App $app) {
$app->task(function () {
return 'HELLO';
});
}
]);
ConsoleMiddleware
Added console middleware for input
and output
interface from Symfony/Console. Output is an instance for SymfonyStyle.
$app->task(function ($context) {
/** @var \Symfony\Component\Console\Style\SymfonyStyle $output */
$output = $this->output;
$output->title("Hello world");
});
Added Database Middleware
see examples/db.php
Multiple option, option callback, DebugMiddleware
Multiple option is now supported.
$app->opt('--email {EMAIL}')
->multiple();
Option callback
The second argument of option() is a callback when option is supplied.
$app->opt('--hello {NAME}', function ($context, $value) {
...
});
DebugMiddleware
Call Debug::enable(). Required symfony/debug
$app->add(\Clim\Middleware\DebugMiddleware::class);
Multiple argument support
Now, argument can be defined to accept multiple values.
$app->arg('arg1')
->multiple();
Container Resolution support
Now you can use container resolution for callbacks.
- container_key:method
- Class:method
- An invokable class
- container_key
See also Slim's documentation:
https://www.slimframework.com/docs/objects/router.html#container-resolution
Support middleware
Middleware support is added on this version. Now you can add extra feature without effort.
Also if closure is passed as a middleware, the container is bound to it as $this
.
Bugfix on examples
Remove unneeded test code.
Initial Release
Very basic features are supported in this release.
- DI Container
- option() / argument() / dispatch() / task()
Following features are not included.
- ResolvableCallable
- Built-in help generation