{"id":16675870,"url":"https://github.com/mpyw/streamable-console","last_synced_at":"2025-05-14T01:32:01.037Z","repository":{"id":45683010,"uuid":"230582656","full_name":"mpyw/streamable-console","owner":"mpyw","description":"Call interactive artisan command using arbitrary stream instead of STDIN.","archived":false,"fork":false,"pushed_at":"2023-03-13T11:52:32.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T13:07:58.526Z","etag":null,"topics":["artisan","artisan-command","automated","automation","cli","command","console","laravel","php","psr-7","stream"],"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/mpyw.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":"2019-12-28T08:37:54.000Z","updated_at":"2024-08-28T01:49:49.000Z","dependencies_parsed_at":"2022-08-28T16:41:16.431Z","dependency_job_id":null,"html_url":"https://github.com/mpyw/streamable-console","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fstreamable-console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fstreamable-console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fstreamable-console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fstreamable-console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpyw","download_url":"https://codeload.github.com/mpyw/streamable-console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225270659,"owners_count":17447635,"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":["artisan","artisan-command","automated","automation","cli","command","console","laravel","php","psr-7","stream"],"created_at":"2024-10-12T13:08:15.080Z","updated_at":"2025-05-14T01:32:01.016Z","avatar_url":"https://github.com/mpyw.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamable Console [![Build Status](https://github.com/mpyw/streamable-console/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/streamable-console/actions) [![Coverage Status](https://coveralls.io/repos/github/mpyw/streamable-console/badge.svg?branch=master)](https://coveralls.io/github/mpyw/streamable-console?branch=master)\n\nCall interactive artisan command using arbitrary stream.\n\n## Requirements\n\n- PHP: `^8.2`\n- Laravel: `^11.0 || ^12.0`\n- [guzzlehttp/psr7](https://github.com/guzzle/psr7): `^2.7`\n\n\u003e [!NOTE]\n\u003e Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.\n\n## Installing\n\n```bash\ncomposer require mpyw/streamable-console\n```\n\n## Usage\n\n### Using Stream\n\n```php\n\u003c?php\n\nnamespace App\\Console\\Commands;\n\nuse Illuminate\\Console\\Command;\n\nclass QuizCommand extends Command\n{\n    protected $signature = 'example:quiz';\n\n    /**\n     * @return int\n     */\n    public function handle(): int\n    {\n        // We need to type \"no\" and press Enter to pass\n        if ($this-\u003econfirm('Is one plus one equals to three?', true)) {\n            return 1;\n        }\n        \n        return 0;\n    }\n}\n```\n\n```php\n\u003c?php\n\nnamespace App\\Console\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Mpyw\\StreamableConsole\\Streamable;\n\nclass RunCommand extends Command\n{\n    use Streamable;\n\n    protected $signature = 'example:run';\n\n    /**\n     * @return int\n     */\n    public function handle(): int\n    {\n        // Type \"no\" and press Enter\n        return $this-\u003eusingInputStream(\"no\\n\")-\u003ecall('example:quiz');\n    }\n}\n```\n\n### Using Infinite Input (`yes` command emulation)\n\n```php\n\u003c?php\n\nnamespace App\\Console\\Commands;\n\nuse Illuminate\\Console\\Command;\n\nclass QuizCommand extends Command\n{\n    protected $signature = 'example:quiz';\n\n    /**\n     * @return int\n     */\n    public function handle(): int\n    {\n        // We need to type \"no\" and press Enter to pass at least for three times\n        if ($this-\u003econfirm('Is one plus one equals to three?', true)) {\n            return 1;\n        }\n        if ($this-\u003econfirm('Is one plus one equals to three?', true)) {\n            return 1;\n        }\n        if ($this-\u003econfirm('Is one plus one equals to three?', true)) {\n            return 1;\n        }\n        \n        return 0;\n    }\n}\n```\n\n```php\n\u003c?php\n\nnamespace App\\Console\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Mpyw\\StreamableConsole\\Streamable;\n\nclass RunCommand extends Command\n{\n    use Streamable;\n\n    protected $signature = 'example:run';\n\n    /**\n     * @return int\n     */\n    public function handle(): int\n    {\n        // Infinitely type \"no\" and press Enter\n        return $this-\u003eusingInfiniteInput(\"no\\n\")-\u003ecall('example:quiz');\n    }\n}\n```\n\nNote that you can use `yes()` as an alias of `usingInfiniteInput()`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Fstreamable-console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpyw%2Fstreamable-console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Fstreamable-console/lists"}