Skip to content

Releases: basuke/Clim

Support parameter binding

26 Apr 05:22
Compare
Choose a tag to compare

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 for array $options
  • $arguments and $args are reserved argument for array $arguments
  • $context are reserved argument for Context $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()

24 Apr 16:48
Compare
Choose a tag to compare
$app = new App();
$app->dispatch('{COMMAND}', [
    'hi|hello' => function (App $app) {
        $app->task(function () {
            return 'HELLO';
        });
    }
]);

ConsoleMiddleware

23 Apr 07:24
Compare
Choose a tag to compare

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

22 Apr 08:00
Compare
Choose a tag to compare

see examples/db.php

Multiple option, option callback, DebugMiddleware

21 Apr 07:34
Compare
Choose a tag to compare

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

20 Apr 06:20
Compare
Choose a tag to compare

Now, argument can be defined to accept multiple values.

$app->arg('arg1')
    ->multiple();

Container Resolution support

19 Apr 06:23
Compare
Choose a tag to compare

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

19 Apr 04:12
Compare
Choose a tag to compare

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

18 Apr 06:05
Compare
Choose a tag to compare

Remove unneeded test code.

Initial Release

18 Apr 04:28
Compare
Choose a tag to compare

Very basic features are supported in this release.

  • DI Container
  • option() / argument() / dispatch() / task()

Following features are not included.

  • ResolvableCallable
  • Built-in help generation