{"id":20140238,"url":"https://github.com/10quality/ayuco","last_synced_at":"2025-04-09T18:23:16.148Z","repository":{"id":56937896,"uuid":"58573775","full_name":"10quality/ayuco","owner":"10quality","description":" Command-Line interface that can be used to execute commands written in PHP.","archived":false,"fork":false,"pushed_at":"2023-02-08T08:57:28.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"v1.0","last_synced_at":"2025-03-23T20:23:09.695Z","etag":null,"topics":[],"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/10quality.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":"2016-05-11T19:17:44.000Z","updated_at":"2023-01-05T18:49:30.000Z","dependencies_parsed_at":"2023-02-04T11:01:12.618Z","dependency_job_id":null,"html_url":"https://github.com/10quality/ayuco","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fayuco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fayuco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fayuco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fayuco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/10quality","download_url":"https://codeload.github.com/10quality/ayuco/tar.gz/refs/heads/v1.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085993,"owners_count":21045249,"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":[],"created_at":"2024-11-13T21:49:51.758Z","updated_at":"2025-04-09T18:23:16.123Z","avatar_url":"https://github.com/10quality.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ayuco\n\n[![Latest Stable Version](https://poser.pugx.org/10quality/ayuco/v/stable)](https://packagist.org/packages/10quality/ayuco)\n[![Total Downloads](https://poser.pugx.org/10quality/ayuco/downloads)](https://packagist.org/packages/10quality/ayuco)\n[![License](https://poser.pugx.org/10quality/ayuco/license)](https://packagist.org/packages/10quality/ayuco)\n\nCommand-Line interface that can be used to execute commands written in PHP.\n\n**Note:** Commands included in this package (excluding help command) were written for WordPress-MVC.\n\n## Usage\n\nCreate a php file that will be called in command-line, [Sample](https://github.com/10quality/ayuco/blob/v1.0/tests/environments/plugin/ayuco), and include the following code lines:\n\n```php\nuse Ayuco\\Listener;\n```\n\nCreate a listener:\n```php\n$ayuco = new Listener();\n\n// or without use\n$ayuco = new Ayuco\\Listener()\n```\n\nRegister your commands.\n```php\n$ayuco-\u003eregister($command1)\n    -\u003eregister($command2)\n    -\u003eregister(new MyCommand);\n```\n\nStart interpreting or listening:\n```php\n$ayuco-\u003einterpret();\n```\n\nUse in command line:\n```bash\nphp filename command_key arguments\n```\n\nIf `filename` is named `ayuco.php` and `command_key` is `clear_cache`, command in *command-line* will be:\n\n```bash\nphp ayuco.php clear_cache\n```\n\n### Arguments and command options\n\nSend arguments right after the `command_key`, for example:\n```bash\nphp ayuco.php cache clear \n```\n\nIn the example above, `cache` will be the command key and `clear` will be an argument (in order, it will be `$arg[2]`).\n\nSend arguments as command options with the prefix `--`, for example:\n```bash\nphp ayuco.php cache clear --debug --note=\"Cache clear note\"\n```\n\n### Create a custom command\n\nCreate your own class command by extending from Ayuco base command class:\n```php\nuse Ayuco\\Command;\n\nclass MyCommand extends Command\n{\n    protected $key = 'command_key';\n\n    protected $description = 'My command description.';\n\n    public function call($args = [])\n    {\n        // TODO command action.\n    }\n}\n```\n\nExample for a clear cache command.\n```php\nuse Ayuco\\Command;\n\nclass ClearCacheCommand extends Command\n{\n    protected $key = 'clear_cache';\n\n    protected $description = 'Clears system cache.';\n\n    public function call($args = [])\n    {\n        Cache::flush(); // Example\n    }\n}\n```\n\nRegistration in listener would be:\n\n```php\n$ayuco-\u003eregister(new ClearCacheCommand);\n```\n\n### Arguments and options\n\nFor this command:\n```bash\nphp ayuco.php cache clear \n```\n\nThe arguments can be accessed like:\n```php\nuse Ayuco\\Command;\n\nclass CacheCommand extends Command\n{\n    protected $key = 'cache';\n\n    public function call($args = [])\n    {\n        // ayuco.php\n        $args[0];\n\n        // cache\n        $args[1];\n\n        // clear\n        $args[2];\n    }\n}\n```\n\nFor this command:\n```bash\nphp ayuco.php cache clear --debug --note=\"Cache clear note\"\n```\n\nThe options can be accessed like:\n```php\nuse Ayuco\\Command;\n\nclass CacheCommand extends Command\n{\n    protected $key = 'cache';\n\n    public function call($args = [])\n    {\n        // ayuco.php\n        $args[0];\n\n        // cache\n        $args[1];\n\n        // clear\n        $args[2];\n\n        // --debug\n        $this-\u003eoptions['debug'];\n\n        // --note=\"...\"\n        $this-\u003eoptions['note'];\n    }\n}\n```\n\n### Coloring output\n\nChange the coloring of the output printed in the console using class `Ayuco\\Coloring` static method `apply()`:\n```php\nuse Ayuco\\Coloring;\nuse Ayuco\\Command;\n\nclass ColoringCommand extends Command\n{\n    public function call($args = [])\n    {\n        $this-\u003e_print(Coloring::apply('red', 'Print this message in red.'));\n    }\n}\n```\n\nYou can read more about coloring [here](https://github.com/php-parallel-lint/PHP-Console-Color).\n\n### Help command\n\nAYUCO automatically will register its own `help` command. This command can be used to display in `command-line` the list of registered commands, use it like:\n\n```bash\nphp ayuco.php help\n```\n\n## Requirements\n\n* PHP \u003e= 5.4\n\n## Coding guidelines\n\nPSR-4.\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 [10Quality](http://www.10quality.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10quality%2Fayuco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F10quality%2Fayuco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10quality%2Fayuco/lists"}