{"id":23461037,"url":"https://github.com/getkirby/cli","last_synced_at":"2025-04-04T18:07:20.741Z","repository":{"id":60843513,"uuid":"540010927","full_name":"getkirby/cli","owner":"getkirby","description":"Kirby Command Line Interface","archived":false,"fork":false,"pushed_at":"2025-01-27T10:13:42.000Z","size":207,"stargazers_count":54,"open_issues_count":6,"forks_count":6,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-28T17:08:45.295Z","etag":null,"topics":["cli","cms","devtools","dx","kirby","kirby3","kirby4","kirby5","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/getkirby.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://getkirby.com/buy"]}},"created_at":"2022-09-22T14:03:54.000Z","updated_at":"2025-01-27T10:13:43.000Z","dependencies_parsed_at":"2023-12-21T13:23:39.103Z","dependency_job_id":"15630e4e-db22-48e6-a381-071a523533b6","html_url":"https://github.com/getkirby/cli","commit_stats":{"total_commits":58,"total_committers":3,"mean_commits":"19.333333333333332","dds":"0.13793103448275867","last_synced_commit":"0e8074b0e6081c9e1a9f31090733b058db15be06"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getkirby","download_url":"https://codeload.github.com/getkirby/cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"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":["cli","cms","devtools","dx","kirby","kirby3","kirby4","kirby5","php"],"created_at":"2024-12-24T07:28:37.679Z","updated_at":"2025-04-04T18:07:20.721Z","avatar_url":"https://github.com/getkirby.png","language":"PHP","funding_links":["https://getkirby.com/buy"],"categories":[],"sub_categories":[],"readme":"# Kirby CLI\n\nThe Kirby command line interface helps simplifying common tasks with your Kirby installations.\n\n## Installation\n\n### Via Composer\n\n```\ncomposer global require getkirby/cli\n```\n\nMake sure to add your composer bin directory to your `~/.bash_profile` (Mac OS users) or into your `~/.bashrc` (Linux users).\n\nYour global composer directory is normally either `~/.composer/vendor/bin` or `~/.config/composer/vendor/bin`. You can find the correct path by running …\n\n```\ncomposer -n config --global home\n```\n\nAfterwards, add the result to your bash profile  …\n\n```\nexport PATH=~/.composer/vendor/bin:$PATH\n```\n\n### Did it work?\n\nCheck if the installation worked by running the following in your terminal.\n\n```\nkirby\n```\n\nThis should print the Kirby CLI version and a list of available commands\n\n## Available core commands\n\n```\n- kirby backup\n- kirby clean:content\n- kirby clear:cache\n- kirby clear:lock\n- kirby clear:logins\n- kirby clear:media\n- kirby clear:sessions\n- kirby download\n- kirby help\n- kirby install\n- kirby install:kit\n- kirby install:repo\n- kirby make:blueprint\n- kirby make:collection\n- kirby make:command\n- kirby make:config\n- kirby make:controller\n- kirby make:language\n- kirby make:model\n- kirby make:plugin\n- kirby make:snippet\n- kirby make:template\n- kirby make:user\n- kirby plugin:install\n- kirby plugin:remove\n- kirby plugin:upgrade\n- kirby register\n- kirby remove:command\n- kirby roots\n- kirby security\n- kirby unzip\n- kirby upgrade\n- kirby uuid:generate\n- kirby uuid:populate\n- kirby uuid:remove\n- kirby version\n```\n\n## Writing commands\n\nYou can create a new command via the CLI:\n\n```bash\nkirby make:command hello\n```\n\nThis will create a new `site/commands` folder in your installation with a new `hello.php` file\n\nThe CLI will already put the basic scaffolding into the file:\n\n```php\n\u003c?php\n\nreturn [\n    'description' =\u003e 'Nice command',\n    'args' =\u003e [],\n    'command' =\u003e static function ($cli): void {\n        $cli-\u003esuccess('Nice command!');\n    }\n];\n```\n\nYou can define your command logic in the command callback. The `$cli` object comes with a set of handy tools to create output, parse command arguments, create prompts and more.\n\n## Global commands\n\nYou might have some commands that you need for all your local Kirby installations. This is where global commands come in handy. You can create a new global command with the `--global` flag:\n\n```bash\nkirby make:command hello --global\n```\n\nThe command file will then be place in `~/.kirby/commands/hello.php` and is automatically available everywhere.\n\n## Command environment\n\nTo load a custom environment config for a particular host, you can set an env variable\n\n```\nenv KIRBY_HOST=production.com kirby mycommand\n```\n\n## Command plugins\n\nYour Kirby plugins can define their own set of commands: https://getkirby.com/docs/reference/plugins/extensions/commands\n\n```php\nKirby::plugin('your/plugin', [\n  'commands' =\u003e [\n    'your-plugin:test' =\u003e [\n      'description' =\u003e 'Nice command',\n      'args' =\u003e [],\n      'command' =\u003e function ($cli) {\n        $cli-\u003esuccess('My first plugin command');\n      }\n    ]\n  ]\n]);\n```\n\n## Check for installed commands\n\nYou can always check back if your commands have been created properly by running `kirby` again\n\n```\nkirby\n```\n\n## Removing commands\n\nOnce you no longer need a command, you can remove it with …\n\n```bash\nkirby remove:command hello\n```\n\nIf you have a local and a global command, you can choose which one to delete.\n\n## Debugging\n\nUse the `-d` or `--debug` argument to run the command in debug mode:\n\n```bash\nkirby make:command hello --debug\n```\n\n## Formatting Output\n\nSending messages to the terminal is super easy.\n\n### $cli-\u003eout()\n\n```php\n$cli-\u003eout('This is some simple text');\n```\n\n### $cli-\u003esuccess()\n\n```php\n$cli-\u003esuccess('This is text in a nice green box');\n```\n\n### $cli-\u003eerror()\n\n```php\n$cli-\u003eerror('This is red text for errors');\n```\n\n### $cli-\u003ebold()\n\n```php\n$cli-\u003ebold('This is some bold text');\n```\n\n### $cli-\u003ebr()\n\n```php\n// this will create a line break\n$cli-\u003ebr();\n```\n\nFor more available colors and formats, check out the CLImate docs: https://climate.thephpleague.com/styling/colors/\n\n## Arguments\n\nYour commands can define a list of required and optional arguments that need to be provided by the user.\n\n```php\n\u003c?php\n\nreturn [\n    'description' =\u003e 'Hello world',\n    'args' =\u003e [\n        'name' =\u003e [\n            'description' =\u003e 'The name for the greeting',\n            'required'    =\u003e true\n        ]\n    ],\n    'command' =\u003e static function ($cli): void {\n        $cli-\u003esuccess('Hello ' . $cli-\u003earg('name') . '!');\n    }\n];\n```\n\nThe command can now be executed by providing the name …\n\n```\nkirby hello Joe\n```\n\nIf no name is provided, an error will be shown.\n\n### Argument docs\n\nArguments can be required, can set a default value and more. Check out the CLImate docs for additional options: https://climate.thephpleague.com/arguments/\n\n## Prompts\n\nInstead of taking arguments from the command, you can also ask for them in a prompt:\n\n```php\n\u003c?php\n\nreturn [\n    'description' =\u003e 'Hello world',\n    'command' =\u003e static function ($cli): void {\n        $name = $cli-\u003eprompt('Please enter a name:');\n        $cli-\u003esuccess('Hello ' . $name . '!');\n    }\n];\n```\n\nAs a third alternative you can either take the argument or ask for it if it is not provided:\n\n```php\n\u003c?php\n\nreturn [\n    'description' =\u003e 'Hello world',\n    'args' =\u003e [\n        'name' =\u003e [\n            'description' =\u003e 'The name for the greeting',\n        ]\n    ],\n    'command' =\u003e static function ($cli): void {\n        $name = $cli-\u003eargOrPrompt('name', 'Please enter a name:');\n        $cli-\u003esuccess('Hello ' . $name . '!');\n    }\n];\n```\n\n## Checkboxes Radios and more\n\nThe CLI also supports more complex ways to get input from users. Check out the CLImate docs how to work with user input: https://climate.thephpleague.com/terminal-objects/input/\n\n## Combining commands\n\nYou can reuse all existing commands in your custom commands to create entire chains of actions.\n\n```php\n\u003c?php\n\nreturn [\n    'description' =\u003e 'Downloads the starterkit and the plainkit',\n    'command' =\u003e static function ($cli): void {\n\n        $cli-\u003ecommand('install:kit', 'starterkit');\n        $cli-\u003ecommand('install:kit', 'plainkit');\n\n        $cli-\u003esuccess('Starterkit and plainkit have been installed');\n    }\n];\n```\n\n## What's Kirby?\n\n- **[getkirby.com](https://getkirby.com)** – Get to know the CMS.\n- **[Try it](https://getkirby.com/try)** – Take a test ride with our online demo. Or download one of our kits to get started.\n- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference and cookbook recipes.\n- **[Issues](https://github.com/getkirby/kirby/issues)** – Report bugs and other problems.\n- **[Feedback](https://feedback.getkirby.com)** – You have an idea for Kirby? Share it.\n- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support.\n- **[Discord](https://chat.getkirby.com)** – Hang out and meet the community.\n- **[YouTube](https://youtube.com/kirbyCasts)** - Watch the latest video tutorials visually with Bastian.\n- **[Mastodon](https://mastodon.social/@getkirby)** – Spread the word.\n- **[Bluesky](https://bsky.app/profile/getkirby.com)** – Tell a friend.\n\n---\n\n© 2009 Bastian Allgeier\n[getkirby.com](https://getkirby.com) · [License agreement](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetkirby%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetkirby%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetkirby%2Fcli/lists"}