{"id":25257519,"url":"https://github.com/czproject/phpcli","last_synced_at":"2025-09-05T10:41:50.961Z","repository":{"id":5241653,"uuid":"6418959","full_name":"czproject/phpcli","owner":"czproject","description":"Helper class for PHP CLI apps.","archived":false,"fork":false,"pushed_at":"2025-06-11T07:37:44.000Z","size":180,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T04:00:45.451Z","etag":null,"topics":["php","php-cli"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"raywenderlich/java-style-guide","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/czproject.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license.md","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},"funding":{"custom":"https://www.janpecha.cz/donate/"}},"created_at":"2012-10-27T16:26:49.000Z","updated_at":"2025-06-11T07:36:32.000Z","dependencies_parsed_at":"2025-02-12T06:40:26.647Z","dependency_job_id":"31e11318-cc9f-4c19-9206-ebe19b02f4a0","html_url":"https://github.com/czproject/phpcli","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/czproject/phpcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Fphpcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Fphpcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Fphpcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Fphpcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czproject","download_url":"https://codeload.github.com/czproject/phpcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Fphpcli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273747727,"owners_count":25160650,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["php","php-cli"],"created_at":"2025-02-12T06:40:17.885Z","updated_at":"2025-09-05T10:41:45.930Z","avatar_url":"https://github.com/czproject.png","language":"PHP","funding_links":["https://www.janpecha.cz/donate/"],"categories":[],"sub_categories":[],"readme":"PHP CLI Console\n===============\n\n[![Build Status](https://github.com/czproject/phpcli/workflows/Build/badge.svg)](https://github.com/czproject/phpcli/actions)\n[![Downloads this Month](https://img.shields.io/packagist/dm/czproject/phpcli.svg)](https://packagist.org/packages/czproject/phpcli)\n[![Latest Stable Version](https://poser.pugx.org/czproject/phpcli/v/stable)](https://github.com/czproject/phpcli/releases)\n[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/czproject/phpcli/blob/master/license.md)\n\n\u003ca href=\"https://www.janpecha.cz/donate/\"\u003e\u003cimg src=\"https://buymecoffee.intm.org/img/donate-banner.v1.svg\" alt=\"Donate\" height=\"100\"\u003e\u003c/a\u003e\n\n\nInstallation\n------------\n\n[Download a latest package](https://github.com/czproject/phpcli/releases) or use [Composer](http://getcomposer.org/):\n\n```\ncomposer require czproject/phpcli\n```\n\nPhpCli requires PHP 5.6 or later, optionaly [Readline extension](http://www.php.net/manual/en/book.readline.php).\n\n\nUsage\n-----\n\n``` php\nuse CzProject\\PhpCli\\ConsoleFactory;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$console = ConsoleFactory::createConsole();\n\n// output\n$console-\u003eoutput('CzProject CLI Simple Console', 'green')\n\t-\u003enl() // new line\n\t-\u003eoutput('Hey!', 'yellow')\n\t-\u003enl()\n\t-\u003eoutput('Fred!', 'blue')\n\t-\u003enl()\n\t-\u003eoutput('Fred is dead!', 'red')\n\t-\u003enl()\n\t-\u003eoutput(['nooooooo...!', ' ', 'But, no problem!'], 'gray')\n\t-\u003enl()\n\t-\u003eoutput('The end.')\n\t-\u003enl();\n\n// input\n$username = $console-\u003einput('Enter your name');\n\n$console-\u003eoutput('Hello! ', 'blue')\n\t-\u003eoutput($username, 'green')\n\t-\u003eoutput(' [user]', 'yellow')\n\t-\u003enl() // print new line\n\t-\u003eoutput('Bye!', 'blue')\n\t-\u003enl();\n\n// input with default value\n$username = $console-\u003einput('Enter your name', 'John');\n\n// confirm\n$agree = $console-\u003econfirm('Do you want to continue?');\n\n// confirm with default value\n$canQuit = $console-\u003econfirm('Really?', TRUE);\n\n// select\n$value = $console-\u003eselect('Select color:', [\n\t'value' =\u003e 'label',\n\t'#ff0000' =\u003e 'Red',\n\t'#00ff00' =\u003e 'Green',\n\t'#0000ff' =\u003e 'Blue',\n]);\n\n// select with default value\n$value = $console-\u003eselect('Select color:', [\n\t'value' =\u003e 'label',\n\t'#ff0000' =\u003e 'Red',\n\t'#00ff00' =\u003e 'Green',\n\t'#0000ff' =\u003e 'Blue',\n], '#ff0000');\n```\n\n\n## Parameters\n\n**Arguments**\n\n```php\n$name = $console-\u003egetArgument(0)-\u003egetValue(); // string|NULL\n\n$size = $console-\u003egetArgument(1, 'int')\n\t-\u003esetRequired()\n\t-\u003eaddRule(function ($value) {\n\t\treturn $value \u003e 0;\n\t})\n\t-\u003egetValue();\n\n$price = $console-\u003egetArgument(2, 'float') // float\n\t-\u003esetDefaultValue(100.0)\n\t-\u003egetValue();\n```\n\n\n**Options**\n\n```php\n$name = $console-\u003egetOption('name')-\u003egetValue(); // string|NULL\n\n$size = $console-\u003egetOption('size', 'int')\n\t-\u003esetRequired()\n\t-\u003eaddRule(function ($value) {\n\t\treturn $value \u003e 0;\n\t})\n\t-\u003egetValue();\n\n$price = $console-\u003egetOption('price', 'float') // float\n\t-\u003esetDefaultValue(100.0)\n\t-\u003egetValue();\n\n$words = $console-\u003egetOption('word')\n\t-\u003esetRepeatable()\n\t-\u003egetValue();\n```\n\n\n**Supported types**\n\n* `string`\n* `int` and `integer`\n* `float`\n* `bool` and `boolean`\n\n--------------------------------------------------------------------------------\n\nLicense: [New BSD License](license.md)\n\u003cbr\u003eAuthor: Jan Pecha, https://www.janpecha.cz/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczproject%2Fphpcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczproject%2Fphpcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczproject%2Fphpcli/lists"}