{"id":20540552,"url":"https://github.com/utopia-php/cli","last_synced_at":"2026-05-05T06:04:54.017Z","repository":{"id":34835526,"uuid":"184115417","full_name":"utopia-php/cli","owner":"utopia-php","description":"Lite \u0026 fast micro PHP framework for building CLI tools that is **easy to learn**.","archived":false,"fork":false,"pushed_at":"2025-03-06T03:35:13.000Z","size":179,"stargazers_count":39,"open_issues_count":9,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T12:05:17.490Z","etag":null,"topics":["hacktoberfest","php"],"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/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2019-04-29T17:36:06.000Z","updated_at":"2024-11-27T18:58:06.000Z","dependencies_parsed_at":"2023-02-15T13:01:11.645Z","dependency_job_id":"ac43eae7-1f39-408a-bfa4-70ac4ab246ea","html_url":"https://github.com/utopia-php/cli","commit_stats":{"total_commits":94,"total_committers":10,"mean_commits":9.4,"dds":0.5106382978723405,"last_synced_commit":"ccb7c8125ffe0254fef8f25744bfa376eb7bd0ea"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247181641,"owners_count":20897370,"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":["hacktoberfest","php"],"created_at":"2024-11-16T01:16:12.213Z","updated_at":"2026-05-05T06:04:54.009Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utopia CLI\n\n[![Build Status](https://travis-ci.org/utopia-php/cli.svg?branch=master)](https://travis-ci.com/utopia-php/cli)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/cli.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244)](https://appwrite.io/discord)\n\nUtopia framework CLI library is simple and lite library for extending Utopia PHP Framework to be able to code command line applications. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nAlthough this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/cli\n```\n\nscript.php\n```php\n\u003c?php\nrequire_once './vendor/autoload.php';\n\nuse Utopia\\Console;\nuse Utopia\\CLI\\CLI;\nuse Utopia\\CLI\\Adapters\\Generic;\nuse Utopia\\Validator\\Wildcard;\n\n$cli = new CLI(new Generic());\n\n$cli\n    -\u003etask('command-name')\n    -\u003eparam('email', null, new Wildcard())\n    -\u003eaction(function ($email) {\n        Console::success($email);\n    });\n\n$cli-\u003erun();\n\n```\n\nAnd than, run from command line:\n\n```bash\nphp script.php command-name --email=me@example.com\n```\n\n### Hooks\n\nThere are three types of hooks, init hooks, shutdown hooks and error hooks. Init hooks are executed before the task is executed. Shutdown hook is executed after task is executed before application shuts down. Finally error hooks are executed whenever there's an error in the application lifecycle. You can provide multiple hooks for each stage.\n\n```php\nrequire_once __DIR__ . '/../../vendor/autoload.php';\n\nuse Utopia\\CLI\\CLI;\nuse Utopia\\Console;\nuse Utopia\\Validator\\Wildcard;\n\nCLI::setResource('res1', function() {\n    return 'resource 1';\n})\n\nCLI::init()\n    inject('res1')\n    -\u003eaction(function($res1) {\n        Console::info($res1);\n    });\n\nCLI::error()\n    -\u003einject('error')\n    -\u003eaction(function($error) {\n        Console::error('Error occurred ' . $error);\n    });\n\n$cli = new CLI();\n\n$cli\n    -\u003etask('command-name')\n    -\u003eparam('email', null, new Wildcard())\n    -\u003eaction(function ($email) {\n        Console::success($email);\n    });\n\n$cli-\u003erun();\n```\n\n## System Requirements\n\nUtopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fcli/lists"}