Skip to content

Commit

Permalink
Update ability to configure from composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanchez committed Aug 31, 2018
1 parent 20369e8 commit 9860900
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,25 @@ craft tail
craft update:assetsindexes
```

## Configuration

Craft CLI can be configured in two ways. You may use the `craft init` command to generate a `.craft-cli.php` file. Or, if you have installed Craft CLI via composer, you may add an `extra` object to your `composer.json` and a `craft-cli` object within the `extra` object:

```
{
"extra": {
"craft-cli": {
"commandDirs": {
"\\Your\\Namespace": "path/to/commands/"
}
}
}
}
```

## Custom Commands

Craft CLI custom commands are [Symfony Console](http://symfony.com/doc/current/components/console/introduction.html) Command objects. You can add custom commands to your `.craft-cli.php` config file by adding the class name to the `commands` array, or by adding a folder path to the `commandDirs` array.
Craft CLI custom commands are [Symfony Console](http://symfony.com/doc/current/components/console/introduction.html) Command objects. You can add custom commands to your `.craft-cli.php` or `composer.json` config by adding a namespace and folder path to the `commandDirs` object.

You can generate a custom command file using the `craft generate:command` command.

Expand Down
10 changes: 0 additions & 10 deletions sample.craft-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,6 @@
*/
'dotenv_path' => __DIR__,

/**
* Custom commands
*
* An array of Command class names of
* custom commands.
*/
'commands' => array(
#'\\Your\\Custom\\Command',
),

/**
* Custom command directories
*
Expand Down
3 changes: 1 addition & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use CraftCli\Command\ExemptFromBootstrapInterface;
use CraftCli\Command\Command as BaseCommand;
use CraftCli\Command\NeedsCraftInterface;
use CraftCli\ClassFinder\ClassFinder;
use CraftCli\Support\ClassFinder;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -18,7 +18,6 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Dotenv\Dotenv;
use ReflectionClass;
use RuntimeException;

class Application extends ConsoleApplication
Expand Down
2 changes: 2 additions & 0 deletions src/Support/ClassFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace CraftCli\Support;

use ReflectionClass;

class ClassFinder
{
/**
Expand Down

0 comments on commit 9860900

Please sign in to comment.