{"id":20916207,"url":"https://github.com/yannoff/console","last_synced_at":"2025-05-13T11:30:29.909Z","repository":{"id":34925142,"uuid":"189641237","full_name":"yannoff/console","owner":"yannoff","description":"A lightweight, simple alternative to symfony/console, designed for easy  PHP applications development.","archived":false,"fork":false,"pushed_at":"2024-03-09T22:39:13.000Z","size":129,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-01T23:07:48.342Z","etag":null,"topics":["console","php-applications","php-cli","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yannoff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2019-05-31T18:34:55.000Z","updated_at":"2023-08-04T22:03:07.000Z","dependencies_parsed_at":"2023-02-19T17:25:16.397Z","dependency_job_id":"5f347ddd-9f2d-4eee-bdfd-15dcfff28f95","html_url":"https://github.com/yannoff/console","commit_stats":{"total_commits":42,"total_committers":1,"mean_commits":42.0,"dds":0.0,"last_synced_commit":"a85b9866ed6170f4165bb05bcae6dd4e9dd398a4"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannoff%2Fconsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannoff%2Fconsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannoff%2Fconsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannoff%2Fconsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yannoff","download_url":"https://codeload.github.com/yannoff/console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932709,"owners_count":21986441,"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":["console","php-applications","php-cli","symfony"],"created_at":"2024-11-18T16:20:33.140Z","updated_at":"2025-05-13T11:30:29.389Z","avatar_url":"https://github.com/yannoff.png","language":"PHP","readme":"# yannoff/console\n\nA simple, lightweight console implementation for command-line PHP applications.\n\n\n[![Latest Stable Version](https://poser.pugx.org/yannoff/console/v/stable)](https://packagist.org/packages/yannoff/console)\n[![Total Downloads](https://poser.pugx.org/yannoff/console/downloads)](https://packagist.org/packages/yannoff/console)\n[![License](https://poser.pugx.org/yannoff/console/license)](https://packagist.org/packages/yannoff/console)\n\n\n## Why are we here ?\n\nThis library was conceived as an alternative to the [symfony/console](https://github.com/symfony/console) component.\n\nTruth is, the symfony component may be good for rapid-application-development or for a proof-of-concept, but on the other hand doesn't seem to be the best option for most use-cases, since only a few among the plenty of available features are necessary.\n\nSo here came the need for the [yannoff/console](https://github.com/yannoff/console) component.\n\nYet the idea was not to [reinvent the wheel](https://sourcemaking.com/antipatterns/reinvent-the-wheel), but merely to provide\na simpler, lighter (in size \u0026 resource) and more POSIX-compliant implementation for PHP command-line applications.\n\n## Installation\n\nVia [composer](https://getcomposer.org/):\n\n```bash\n$ composer require yannoff/console\n```\n\n## Usage\n\nHere is a _Hello World_ command example:\n\nFirst the application script, the script that will be invoked using `php bin/app.php`\n\n```php\n#!/usr/bin/env php\n\u003c?php\n// bin/app.php\n\n// Mute PHP deprecation warnings \u0026 notices\nerror_reporting(E_ERROR);\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\nuse Yannoff\\Component\\Console\\Application;\nuse Acme\\Demo\\HelloCommand;\n\n$application = new Application('acme', '0.0.0');\n\n$application-\u003eaddCommands([\n    new HelloCommand('hello'),\n]);\n\n$application-\u003erun();\n```\n\nThen the command file:\n\n```php\n\u003c?php\n// src/Acme/Demo/\n\nnamespace Acme\\Demo;\n\nuse Yannoff\\Component\\Console\\Command;\nuse Yannoff\\Component\\Console\\Definition\\Argument;\nuse Yannoff\\Component\\Console\\Definition\\Option;\n\nclass HelloCommand extends Command\n{\n    public function configure()\n    {\n        $this\n            -\u003esetName('hello')\n            -\u003esetHelp('Hello world')\n            -\u003esetDescription('Hello world demo application')\n            -\u003eaddArgument(\n                'name',\n                Argument::OPTIONAL,\n                'Optional name to greet'\n            )\n            -\u003eaddOption(\n                'upper',\n                'u',\n                Option::FLAG,\n                'Print the greetings in upper case'\n            )\n            ;\n    }\n\n    public function execute()\n    {\n        $name = $this-\u003egetArgument('name');\n        $upper = $this-\u003egetOption('upper');\n\n        $message = 'Hello ' . (null === $name ? 'World' : $name);\n        if ($upper) {\n            $message = strtoupper($message);\n        }\n\n        $this-\u003ewrite($message);\n\n        return 0;\n    }\n}\n\n\n```\n\n\u003c!--\nTake a look at the [API Reference](doc/api/index.md) for a full overview of the component classes \u0026 methods.\n--\u003e\n\nPeople willing to migrate from symfony/console may want to have a look at the [migration](doc/migrating.md) section of the documentation.\n\n## Licence\n\nLicensed under the [MIT Licence](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannoff%2Fconsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyannoff%2Fconsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannoff%2Fconsole/lists"}