{"id":36385505,"url":"https://github.com/jabernardo/console.php","last_synced_at":"2026-01-11T15:01:38.191Z","repository":{"id":56995365,"uuid":"121955142","full_name":"jabernardo/console.php","owner":"jabernardo","description":"Command-line Application Skeleton for PHP","archived":false,"fork":false,"pushed_at":"2021-04-02T13:01:00.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T02:45:33.996Z","etag":null,"topics":["command-line","command-line-arguments-parser","php-cli"],"latest_commit_sha":null,"homepage":null,"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/jabernardo.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}},"created_at":"2018-02-18T13:38:06.000Z","updated_at":"2021-04-02T13:01:03.000Z","dependencies_parsed_at":"2022-08-21T10:40:49.140Z","dependency_job_id":null,"html_url":"https://github.com/jabernardo/console.php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jabernardo/console.php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabernardo%2Fconsole.php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabernardo%2Fconsole.php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabernardo%2Fconsole.php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabernardo%2Fconsole.php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabernardo","download_url":"https://codeload.github.com/jabernardo/console.php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabernardo%2Fconsole.php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28309543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["command-line","command-line-arguments-parser","php-cli"],"created_at":"2026-01-11T15:01:21.037Z","updated_at":"2026-01-11T15:01:38.176Z","avatar_url":"https://github.com/jabernardo.png","language":"PHP","readme":"# console.php\n`console.php` is a skeleton for php command-line application.\n\n```php\n\n#!/usr/bin/php\n\u003c?php\n\n// Require autoloader for console.php\nrequire(\"../src/autoload.php\");\n\n// Sample Command Implementation using \\Console\\Command Interface\n// ./index.php hello name:\"Your Name\" age:22\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        if (!$i-\u003ehasOptions(['name', 'age'])) {\n            $o-\u003ewriteln('Invalid args.');\n            return;\n        }\n\n        $o-\u003ewriteln('Hello %s! So you are %d years old.', $i-\u003egetOption('name'), $i-\u003egetOption('age'));\n    }\n}\n\n// Instantiate a new console application\n$app = new \\Console\\Application();\n\n// Register our test HelloCommand to our console application\n$app-\u003eadd('hello', new HelloCommand());\n\n// You can also just declare a command by using callables\n$app-\u003eadd('help', function($i, $o) {\n    $o-\u003ewriteln('This is a sample application.');\n}, true); // \u003c-- `true` is to enable this as the default command\n\n// Finally, App and Running!\n$app-\u003erun();\n\n```\n\n## Input\n\n### hasFlag `:boolean`\nCheck if flag was passed on application.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        // Check if flag exists\n        if ($i-\u003ehasFlag('q')) {\n            // Do something\n        }\n    }\n}\n\n```\n\n### hasOption `:boolean`\nCheck if option was passed on application.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        // Check if option exists\n        if ($i-\u003ehasOption('max')) {\n            // Do something\n        }\n    }\n}\n\n```\n\n### hasOptions `:boolean`\nCheck if option(s) was passed on application.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        // Check if option exists\n        if ($i-\u003ehasOptions(['age', 'name'])) {\n            // Do something\n        }\n    }\n}\n\n```\n\n### getOption `:mixed`\nReturns the value of option being passed on.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    private $max = 0;\n    \n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        // Check if option exists\n        if ($i-\u003ehasOption('max')) {\n            $this-\u003emax = $i-\u003egetOption('max');\n        }\n    }\n}\n\n```\n\n### getOptions `:array`\nReturns all options.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        $options = $i-\u003egetOptions();\n    }\n}\n\n```\n\n### setOptionDelimeter `:void`\nSet option delimeter (default value is `:`)\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        $i-\u003esetOptionDelimeter('=');\n        $options = $i-\u003egetOptions();\n    }\n}\n\n```\n\n### getOptionDelimeter `:string`\nGet option delimeter (default value is `:`)\n\n\n### getParameters `:array`\nReturns all parameters.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        $params = $i-\u003egetParameters();\n    }\n}\n\n```\n\n## Output\n\n### write `:void`\nWrite string buffer.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        $o-\u003ewrite('Hello %s!', $i-\u003egetOption('name'));\n    }\n}\n\n```\n\n### writeln `:void`\nWrite a line of string.\n\n```php\n\u003c?php\n\nclass HelloCommand implements \\Console\\Command {\n    function __invoke(\\Console\\Input $i, \\Console\\Output $o) {\n        $o-\u003ewrite('Hello %s! So you\\'re %d years old.', $i-\u003egetOption('name'), $i-\u003egetOption('age'));\n    }\n}\n\n```\n\n## License\n\nThe `console.php` is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabernardo%2Fconsole.php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabernardo%2Fconsole.php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabernardo%2Fconsole.php/lists"}