innmind / cli-framework
CLI framework
Requires
- php: ~7.4|~8.0
- innmind/cli: ~2.0
- innmind/debug: ^2.0
- innmind/di: ^1.0
- innmind/operating-system: ^2.1
- innmind/silent-cartographer: ^2.0
- innmind/stack: ^1.1
- symfony/dotenv: ^5.0
Requires (Dev)
- innmind/black-box: ^4.3
- innmind/coding-standard: ^1.1
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2023-01-01 15:05:15 UTC
README
Small library on top of innmind/cli
to automatically enable some features.
Installation
composer require innmind/cli-framework
Usage
<?php use Innmind\CLI\{ Environment, Command, }; use Innmind\CLI\Framework\{ Application, Main, }; use Innmind\OperatingSystem\OperatingSystem; use Innmind\Url\Path; new class extends Main { protected function configure(Application $app): Application { return $app ->configAt(Path::of('/path/to/config/directory/')) ->commands(fn(Environment $env, OperatingSystem $os): array => [ // a list of objects implementing Command ]); } }
This simple example will try to locate a file named .env
in the directory provided and will add the variables to the map returned by $env->variables()
in the commands
callable.
By default it enables the usage of innmind/silent-cartographer
, but can be disabled by calling ->disableSilentCartographer()
.
When a PROFILER
environment variable is declared it will enable innmind/debug
, you can disable specific sections of the profiler by calling ->disableProfilerSection(...$sectionsClassNameToDisable)
.
When your CLI application communicate with external services you should call ->useResilientOperatingSystem()
so it accomodate inconsistencies due to unreliable network.