-
Notifications
You must be signed in to change notification settings - Fork 13
Third Party Commands
Rob Sanchez edited this page Oct 11, 2014
·
2 revisions
ExpressionEngine addons can add custom commands to eecli using the eecli_add_commands
hook:
public function eecli_add_commands($commands, $app)
{
if (ee()->extensions->last_call !== FALSE)
{
$commands = ee()->extensions->last_call;
}
require_once PATH_THIRD.'my_addon/src/MyCustomCommand.php';
$commands[] = new MyCustomCommand();
return $commands;
}
Composer libraries can add custom commands to eecli by using the file
autoload feature of composer. In your composer.json:
"autoload": {
"psr-4": { "YourNamespace\\": "src/" },
"files": ["src/register.php"]
}
And then in your register.php
:
<?php
if (php_sapi_name() !== 'cli') {
exit;
}
use eecli\Application;
# the name of a Command class
Application::registerGlobalCommand('\\YourNamespace\\FooCommand');
# or a callback which returns a Command object
Application::registerGlobalCommand(function () {
return new \YourNamespace\BarCommand();
});
See the (Cowsay)[https://github.com/rsanchez/eecli-cowsay] repo as an example of a third party command.
- create:category
- create:category_group
- create:channel
- create:field:<fieldtype>
- create:field_group
- create:global_variable
- create:member
- create:member_group
- create:snippet
- create:status
- create:status_group
- create:template
- create:template_group
- create:upload_pref