decodelabs / clip
CLI kernel integration for DecodeLabs Genesis
Installs: 10 795
Dependents: 5
Suggesters: 1
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- composer-runtime-api: ^2.2
- decodelabs/archetype: ^0.3
- decodelabs/atlas: ^0.12
- decodelabs/dictum: ^0.6
- decodelabs/exceptional: ^0.4.3
- decodelabs/fluidity: ^0.3.3
- decodelabs/genesis: ^0.9
- decodelabs/glitch: ^0.18.5
- decodelabs/terminus: ^0.10
Requires (Dev)
- decodelabs/phpstan-decodelabs: ^0.6.1
README
CLI kernel integration for DecodeLabs Genesis
Clip provides a framework for building comprehensive CLI based applications on top of Genesis.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/clip
Usage
Clip is a middleware library that provides an out-of-the-box setup for implementing a Genesis based CLI task runner. This means you don't really interact with it much, except when setting up the core of your task running infrastructure.
Create your Hub
Define your Genesis Hub by extending Clip's abstract implementation:
namespace MyThing; use DecodeLabs\Archetype; use DecodeLabs\Clip\Controller as ControllerInterface; use DecodeLabs\Clip\Hub as ClipHub; use DecodeLabs\Clip\Task as TaskInterface; use DecodeLabs\Veneer; use MyThing; use MyThing\Controller; use MyThing\Task; class Hub extends ClipHub { public function initializePlatform(): void { parent::initializePlatform(); // Load tasks from local namespace Archetype::map(TaskInterface::class, Task::class); // Create and load your controller (or use Generic) $controller = new Controller(); $this->context->container->bindShared(ControllerInterface::class, $controller); $this->context->container->bindShared(Controller::class, $controller); // Bind your controller with Veneer Veneer::register(Controller::class, MyThing::class); } }
With this hub in place, you can run tasks defined in your nominated namespace from the terminal via a bin defined in composer:
namespace MyThing; use DecodeLabs\Genesis; use MyThing\Hub; require_once $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php'; Genesis::run(Hub::class);
{ "bin": [ "bin/thing" ] }
Define your task:
namespace MyThing\Task; use DecodeLabs\Clip\Task; class MyTask implements Task { public function execute(): bool { // Do the thing return true; } }
composer exec thing my-task # or with effigy effigy thing my-task
Extending
Use the MyThing
Controller Veneer frontage to run sub-tasks, and build on it to create your library's ecosystem with an easily accessed root.
See Effigy and Zest for examples.
Licensing
Clip is licensed under the MIT License. See LICENSE for the full license text.