{"id":19327676,"url":"https://github.com/antidot-framework/antidot-cli","last_synced_at":"2025-04-22T21:30:31.091Z","repository":{"id":46292006,"uuid":"180003221","full_name":"antidot-framework/antidot-cli","owner":"antidot-framework","description":"Symfony console component tweaked for Antidot Framework","archived":false,"fork":false,"pushed_at":"2024-05-22T18:54:18.000Z","size":44,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"3.x.x","last_synced_at":"2025-04-18T17:23:49.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cli.antidotfw.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antidot-framework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kpicaza"]}},"created_at":"2019-04-07T18:01:46.000Z","updated_at":"2024-05-22T18:54:21.000Z","dependencies_parsed_at":"2024-05-22T20:06:00.101Z","dependency_job_id":null,"html_url":"https://github.com/antidot-framework/antidot-cli","commit_stats":{"total_commits":38,"total_committers":5,"mean_commits":7.6,"dds":0.368421052631579,"last_synced_commit":"c68a1cf52f464b61b40722fbc4301b71f33eb647"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fantidot-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fantidot-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fantidot-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Fantidot-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antidot-framework","download_url":"https://codeload.github.com/antidot-framework/antidot-cli/tar.gz/refs/heads/3.x.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250328088,"owners_count":21412555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T02:18:07.609Z","updated_at":"2025-04-22T21:30:30.747Z","avatar_url":"https://github.com/antidot-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/kpicaza"],"categories":[],"sub_categories":[],"readme":"# Antidot Framework Console Tool\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/badges/build.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/build-status/master)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/antidot-framework/antidot-cli/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)\n\nThis library is an adapter for using the [Symfony Console component](https://symfony.com/doc/current/components/console.html) \nusing the standard Zend Framework configuration and any dependency injection container compatible with \nthe `Psr\\ContainerInterface`\n\n## Install\n\nUsing composer package manager\n\n````bash\ncomposer require antidot-fw/cli\n````\n\n### Antidot Framework:\n\nThe Cli component is installed by default in [Antidot Framework Starter](https://github.com/antidot-framework/antidot-starter)\n\n### Zend Expressive:\n\nThe Cli component will be automatically installed by running composer require command when we have previously \ninstalled the library [Zend Config Aggregator](https://github.com/zendframework/zend-config-aggregator)\n\nAll we'll need to do is create the Console entry point:\n\n````php\n#!/usr/bin/env php\n\u003c?php\n// bin/console\n\ndeclare(strict_types=1);\n\nuse Antidot\\Cli\\Application\\Console;\n\nset_time_limit(0);\n\ncall_user_func(static function (): void {\n    require __DIR__.'/../vendor/autoload.php';\n    $container = require __DIR__.'/../config/container.php';\n    $console = $container-\u003eget(Console::class);\n\n    $console-\u003erun();\n});\n````\n\nFinally we will give execution permissions to the file `bin/console`\n\n````bash\n# Debian systems\nchmod +x bin/console\n````\n\n### As Standalone application\n\nThe Cli component can also be used to create console applications without any Framework, \nall we need is an implementation of the dependency injection container compatible with the \nstandard `Psr\\ContainerInterface`\n\nAssuming we create a project with the following structure:\n\n````\nbin/console\nconfig/container.php\ncomposer.json\n````\n\nAs a dependency we could use the [Antidot Framework adapter For Aura Container](https://github.com/antidot-framework/aura-container-config)\n\n````json\n# composer.json\n{\n    \"name\": \"antidot-fw/console-example\",\n    \"description\": \"Antidot framework console project example\",\n    \"type\": \"project\",\n    \"require\": {\n        \"antidot-fw/cli\": \"dev-master\",\n        \"antidot-fw/aura-container-config\": \"dev-master\"\n    },\n    \"require-dev\": {\n        \"symfony/var-dumper\": \"^4.3\"\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"App\\\\\": \"src\"\n        }\n    }\n}\n````\n\nWe create the file `config/container.php` that must return a configured instance of `Psr\\ContainerInterface` to us.\n\n````php\n\u003c?php\n// config/container.php\nuse Aura\\Di\\ContainerBuilder;\nuse Antidot\\Aura\\Container\\Config\\ContainerConfig;\n\n// Load configuration\n$config = [ 'dependencies' =\u003e [], 'console' =\u003e [ 'commands' =\u003e [] ] ];\n// Build container\n$builder = new ContainerBuilder();\nreturn $builder-\u003enewConfiguredInstance([\n    new ContainerConfig(\\is_array($config) ? $config : []),\n], $builder::AUTO_RESOLVE);\n````\n\nWe need to create the Console entry point:\n\n````php\n\u003c?php\n// bin/console\n\ndeclare(strict_types=1);\n\nuse Antidot\\Cli\\Application\\Console;\n\nset_time_limit(0);\n\ncall_user_func(static function (): void {\n    require __DIR__.'/../vendor/autoload.php';\n    $container = require __DIR__.'/../config/container.php';\n    $console = $container-\u003eget(Console::class);\n\n    $console-\u003erun();\n});\n````\n\nAnd give to it execution permissions\n\n````bash\n# Debian systems\nchmod +x bin/console\n````\n\n## Usage\n\nUna vez instalada la Consola, podemos ver los comndos disponibles ejecutando el punto de entrada con el parametro \n`list` o sin parametro\n\n````bash\nbin/console\n````\n\n### Create Commands\n\nTo create console commands you need to create a class that extends from `Symfony\\Component\\Console\\Command\\Command` \n\n````php\n\u003c?php\n// src/Console/SomeCommand\n\ndeclare(strict_types=1);\n\nnamespace App\\Console\\Command;\n\nuse Symfony\\Component\\Console\\Command\\Command;\nuse Symfony\\Component\\Console\\Input\\InputInterface;\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\nuse SomeDependency;\n\nclass SomeCommand extends Command\n{\n    /**\n     * You can inject dependencies by constructor \n     * @var SomeDependency \n     */\n    private $dependency;\n    \n    public function __construct(SomeDependency $dependency) {\n        $this-\u003edependency = $dependency;\n        parent::__construct();\n    }\n    \n    protected function configure(): void\n    {\n        $this-\u003esetName('some:command:name');\n    }\n    \n    protected function execute(InputInterface $input, OutputInterface $output): void\n    {\n        $output-\u003ewriteLn('Hello World!!!');        \n    }\n}\n````\n\nFor more information you can see [the official documentation](https://symfony.com/doc/current/console.html) of Symfony in this regard.\n\n### Config\n\nThe configuration consists of three different elements: `dependencies`, `console.commands` y `console.helper-sets`\n\n````php\n\u003c?php\n$config =  [\n   'config_cache_path' =\u003e 'var/cache/config-cache.php',\n   'dependencies' =\u003e [\n       'invokables' =\u003e [\n            SomeCommandClass::class =\u003e SomeCommandClass::class,\n            SomeHelperSet::class =\u003e SomeHelperSet::class,\n        ]\n   ],\n   'console' =\u003e [\n       'commands' =\u003e [\n           'some:command:name' =\u003e SomeCommandClass::class\n       ],\n       'helper-sets' =\u003e [\n            SomeHelperSet::class\n        ]\n   ]\n];\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Fantidot-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantidot-framework%2Fantidot-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Fantidot-cli/lists"}