docs(articles): From Magento to Symfony, a requalification guide grouped into sections
uk/articles/magento-to-symfony/infrastructure/cli.md
новий файл +70
−0
1
+
# CLI і деплой
2
+
3
+
| bin/magento | bin/console | Примітка |
4
+
|---|---|---|
5
+
| cache:flush, cache:clean | cache:clear; cache:pool:clear cache.app | Системний кеш і дані — різні речі. |
6
+
| setup:upgrade | doctrine:migrations:migrate | Лише схема й дані з міграцій. |
7
+
| setup:db-declaration:generate-whitelist | make:migration, doctrine:migrations:diff | Генерує клас міграції. |
8
+
| setup:di:compile | cache:warmup | У prod виконується під час cache:clear. |
9
+
| deploy:mode:set production | APP_ENV=prod, APP_DEBUG=0 | Плюс composer dump-env prod. |
10
+
| module:enable / module:status | config/bundles.php; about | about показує версію, середовище, шляхи. |
11
+
| dev:di:info | debug:container, debug:autowiring | Плюс lint:container. |
12
+
| config:show | debug:config, config:dump-reference | Фактичні значення і всі можливі опції. |
13
+
| — | debug:router, router:match | Маршрути. |
14
+
| — | debug:event-dispatcher | Слухачі з пріоритетами. |
15
+
| queue:consumers:start | messenger:consume async | Після деплою: messenger:stop-workers. |
16
+
| cron:run | messenger:consume scheduler_default | Або системний cron. |
17
+
| indexer:reindex | ваша команда | Індексаторів немає. |
18
+
| admin:user:create | ваша команда, fixtures | Користувачі — ваша сутність. |
19
+
| — | make:controller, make:entity, make:crud, make:command | MakerBundle генерує заготовки. |
20
+
| — | lint:yaml, lint:container, doctrine:schema:validate | Варто запускати в CI. |
21
+
22
+
**Magento** · команда
23
+
24
+
```php
25
+
class ImportCommand extends Command
26
+
{
27
+
protected function configure(): void
28
+
{
29
+
$this->setName('vendor:faq:import');
30
+
}
31
+
protected function execute(InputInterface $input, OutputInterface $output): int
32
+
{
33
+
return Command::SUCCESS;
34
+
}
35
+
}
36
+
// + реєстрація в di.xml у CommandList
37
+
```
38
+
39
+
**Symfony** · команда (той самий Console)
40
+
41
+
```php
42
+
#[AsCommand(name: 'app:faq:import', description: 'Import FAQ from CSV')]
43
+
final class ImportCommand extends Command
44
+
{
45
+
public function __construct(private Importer $importer)
46
+
{
47
+
parent::__construct();
48
+
}
49
+
50
+
protected function execute(InputInterface $input, OutputInterface $output): int
51
+
{
52
+
$io = new SymfonyStyle($input, $output);
53
+
$io->success('Imported');
54
+
return Command::SUCCESS;
55
+
}
56
+
}
57
+
// реєстрації не треба: autoconfigure
58
+
```
59
+
60
+
## Деплой у prod
61
+
62
+
**Symfony** · типова послідовність
63
+
64
+
```bash
65
+
composer install --no-dev --optimize-autoloader
66
+
composer dump-env prod
67
+
APP_ENV=prod bin/console cache:clear # і прогріває кеш
68
+
bin/console doctrine:migrations:migrate --no-interaction
69
+
bin/console messenger:stop-workers # supervisor підніме воркери з новим кодом
70
+
```