|
15 | 15 |
|
16 | 16 | DotKernel component to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli). |
17 | 17 |
|
18 | | -### Requirements |
| 18 | +## Requirements |
| 19 | + |
19 | 20 | - PHP >= 8.2 |
20 | 21 | - laminas/laminas-servicemanager >= 3.11, |
21 | 22 | - laminas/laminas-cli >= 1.4 |
22 | 23 |
|
| 24 | +## Setup |
| 25 | + |
| 26 | +### 1. Install package |
23 | 27 |
|
24 | | -### Setup |
25 | | -#### 1. Install package |
26 | 28 | Run the following command in your application's root directory: |
27 | 29 |
|
28 | 30 | composer require dotkernel/dot-cli |
29 | 31 |
|
30 | | -#### 2. Register ConfigProvider |
| 32 | +### 2. Register ConfigProvider |
| 33 | + |
31 | 34 | Open your application's `config/config.php` and the following line under the _DK packages_ comment: |
32 | 35 |
|
33 | 36 | Dot\Cli\ConfigProvider::class, |
34 | 37 |
|
35 | | -#### 3. Copy bootstrap file |
| 38 | +### 3. Copy bootstrap file |
| 39 | + |
36 | 40 | Locate file `bin/cli.php` in this package, then copy it to your application's `bin/` directory. |
37 | 41 | This is the bootstrap file you will use to execute your commands with. |
38 | 42 |
|
39 | | -#### 4. Copy config file |
| 43 | +### 4. Copy config file |
| 44 | + |
40 | 45 | Locate in this package the following file `config/autoload/cli.global.php` then copy it to your application's `config/autoload/` directory. |
41 | 46 | This is the config file you will add your commands to. |
42 | 47 |
|
| 48 | +## Testing |
43 | 49 |
|
44 | | -### Testing |
45 | 50 | Using the command line, go to your application's root directory, then type the following command: |
46 | 51 |
|
47 | 52 | php /bin/cli.php |
48 | 53 |
|
49 | 54 | The output should look similar to this, containing information on how to start using dot-cli: |
50 | | -```text |
51 | | -DotKernel CLI 1.0.0 |
52 | | -
|
53 | | -Usage: |
54 | | - command [options] [arguments] |
55 | | -
|
56 | | -Options: |
57 | | - -h, --help Display help for the given command. When no command is given display help for the list command |
58 | | - -q, --quiet Do not output any message |
59 | | - -V, --version Display this application version |
60 | | - --ansi Force ANSI output |
61 | | - --no-ansi Disable ANSI output |
62 | | - -n, --no-interaction Do not ask any interactive question |
63 | | - -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
64 | | -
|
65 | | -Available commands: |
66 | | - help Display help for a command |
67 | | - list List commands |
68 | | - demo |
69 | | - demo:command Demo command description. |
70 | | -``` |
| 55 | + |
| 56 | + DotKernel CLI 1.0.0 |
| 57 | + |
| 58 | + Usage: |
| 59 | + command [options] [arguments] |
| 60 | + |
| 61 | + Options: |
| 62 | + -h, --help Display help for the given command. When no command is given display help for the list command |
| 63 | + -q, --quiet Do not output any message |
| 64 | + -V, --version Display this application version |
| 65 | + --ansi Force ANSI output |
| 66 | + --no-ansi Disable ANSI output |
| 67 | + -n, --no-interaction Do not ask any interactive question |
| 68 | + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
| 69 | + |
| 70 | + Available commands: |
| 71 | + help Display help for a command |
| 72 | + list List commands |
| 73 | + demo |
| 74 | + demo:command Demo command description. |
| 75 | + |
71 | 76 | As shown in `config/autoload/cli.global.php`, dot-cli includes a demo command `demo:command` that will help you understand the basics of creating a new command. |
72 | 77 | For more information, see [laminas-cli documentation](https://docs.laminas.dev/laminas-cli/). |
73 | 78 |
|
74 | | -### Setting up as cronjob |
75 | | -```text |
76 | | -* * * * * /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/bin/cli.php demo:command -q |
77 | | -``` |
| 79 | +## Setting up as cronjob |
| 80 | + |
| 81 | + * * * * * /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/bin/cli.php demo:command -q |
| 82 | + |
78 | 83 | or |
79 | | -```text |
80 | | -* * * * * cd /var/www/vhosts/example.com/httpdocs/bin && /opt/plesk/php/7.4/bin/php ./cli.php demo:command -q |
81 | | -``` |
| 84 | + |
| 85 | + * * * * * cd /var/www/vhosts/example.com/httpdocs/bin && /opt/plesk/php/7.4/bin/php ./cli.php demo:command -q |
| 86 | + |
82 | 87 | Adapt the command to your specifications by replacing **7.4** with your PHP version and **example.com** with your domain name. |
83 | 88 |
|
84 | 89 | Note the **-q** (or **--quiet**) option at the end of the command - it serves as a flag to inform the Application that no output should be returned (unless it's an error). |
85 | 90 |
|
86 | 91 | ## License |
| 92 | + |
87 | 93 | MIT |
0 commit comments