|
1 |
| -# Apitte\Console |
| 1 | +# Apitte Console |
2 | 2 |
|
3 |
| -## Content |
| 3 | +Console commands for [Apitte](https://github.com/apitte/core). |
4 | 4 |
|
5 |
| -- [Installation - how to register a plugin](#installation) |
6 |
| -- [Configuration - all options](#configuration) |
7 |
| -- [Usage - controller showtime](#usage) |
| 5 | +## Setup |
8 | 6 |
|
9 |
| -## Installation |
| 7 | +First of all, setup [core](https://github.com/apitte/core) package. |
10 | 8 |
|
11 |
| -This plugin requires [Apitte/Core](https://github.com/apitte/core) library. |
| 9 | +Install and register console plugin |
12 | 10 |
|
13 |
| -At first you have to register the main extension. |
14 |
| - |
15 |
| -```yaml |
16 |
| -extensions: |
17 |
| - api: Apitte\Core\DI\ApiExtension |
| 11 | +```bash |
| 12 | +composer require apitte/console |
18 | 13 | ```
|
19 | 14 |
|
20 |
| -Secondly, add the `ConsolePlugin` plugin. |
21 |
| - |
22 | 15 | ```yaml
|
23 | 16 | api:
|
24 | 17 | plugins:
|
25 | 18 | Apitte\Console\DI\ConsolePlugin:
|
26 | 19 | ```
|
27 | 20 |
|
28 |
| -## Configuration |
29 |
| - |
30 |
| -```yaml |
31 |
| -api: |
32 |
| - plugins: |
33 |
| - Apitte\Console\DI\ConsolePlugin: |
34 |
| - |
35 |
| -services: |
36 |
| - - Apitte\Console\Command\RouteDumpCommand |
37 |
| -``` |
38 |
| - |
39 |
| -## Usage |
40 |
| - |
41 |
| -To execute prepared commands you will need Symfony Console Application. Don't waste your time to implement it |
42 |
| -and use [prepared solution](#console) from Contributte/Console. |
43 |
| - |
44 |
| -With Contributte/Console you could call `bin/console` and see the magic. |
45 |
| - |
46 |
| -``` |
47 |
| -php bin/console apitte:<> |
48 |
| -``` |
49 |
| -
|
50 |
| -| Command | Description | |
51 |
| -|---------|-------------| |
52 |
| -| apitte:route:dump | List all endpoints and their details | |
53 |
| -
|
54 |
| -## Console |
| 21 | +You also need setup an integration of [symfony/console](https://symfony.com/doc/current/components/console.html), try [contributte/console](https://github.com/contributte/console/) |
55 | 22 |
|
56 |
| -Take a look at [Contributte/Console](https://github.com/contributte/console). |
| 23 | +If you use [kdyby/console](https://github.com/Kdyby/Console) then make sure you add required tag to registered commands. |
57 | 24 |
|
58 |
| -Install it via composer. |
59 |
| -
|
60 |
| -``` |
61 |
| -composer require contributte/console |
62 |
| -``` |
63 |
| -
|
64 |
| -And setup your NEON. |
65 |
| -
|
66 |
| -``` |
67 |
| -extensions: |
68 |
| - console: Contributte\Console\DI\ConsoleExtension |
| 25 | +```yaml |
| 26 | +decorator: |
| 27 | + Symfony\Component\Console\Command\Command: |
| 28 | + tags: [kdyby.console.command] |
69 | 29 | ```
|
70 | 30 |
|
71 |
| -At least create `<project>/bin/console` and make it executable. |
72 |
| -
|
73 |
| -``` |
74 |
| -#!/usr/bin/env php |
75 |
| -<?php |
| 31 | +## Commands |
76 | 32 |
|
77 |
| -/** @var Nette\DI\Container $container */ |
78 |
| -$container = require __DIR__ . '/../app/bootstrap.php'; |
| 33 | +### Route dump |
79 | 34 |
|
80 |
| -// Get application from DI container. |
81 |
| -$application = $container->getByType(Contributte\Console\Application::class); |
| 35 | +List all endpoints and their details |
82 | 36 |
|
83 |
| -// Run application. |
84 |
| -exit($application->run()); |
| 37 | +```bash |
| 38 | +php bin/console apitte:route:dump |
85 | 39 | ```
|
0 commit comments