File tree 4 files changed +98
-1
lines changed
4 files changed +98
-1
lines changed Original file line number Diff line number Diff line change @@ -223,9 +223,47 @@ mklink "upload" "../../upload" /j
223
223
224
224
Далее необходимо настроить веб-сервер для работы с новым сайтом.
225
225
226
+ # # Composer scripts
227
+
228
+ Приложено пару примеров скриптов для composer, запускающимся по событиям ` post-update` и ` post-install` .
229
+
230
+ - ` Local\C omposerScript\R unMigrationsHandler` - запускает миграции.
231
+
232
+ - ` Local\C omposerScript\C acheWarmerHandler` - убивает и прогревает кэш.
233
+
234
+ Добавить в секцию ` scripts` файла ` composer.json` :
235
+
236
+ ` ` ` json
237
+ " scripts" : {
238
+ " post-update-cmd" : [
239
+ " Local\\ ComposerScript\\ RunMigrationsHandler::doInstall" ,
240
+ " Local\\ ComposerScript\\ CacheWarmerHandler::doInstall"
241
+ ],
242
+ " post-install-cmd" : [
243
+ " Local\\ ComposerScript\\ RunMigrationsHandler::doInstall" ,
244
+ " Local\\ ComposerScript\\ CacheWarmerHandler::doInstall"
245
+ ],
246
+ " cache:warm" : " Local\\ ComposerScript\\ CacheWarmerHandler::doInstall" ,
247
+ " migrations:run" : " Local\\ ComposerScript\\ RunMigrationsHandler::doInstall"
248
+ },
249
+ ` ` `
250
+
251
+ Появятся команды:
252
+
253
+ ` ` ` sh
254
+ composer cache:warm
255
+ ` ` `
256
+
257
+ и
258
+
259
+ ` ` ` sh
260
+ composer migrations:run
261
+ ` ` `
262
+
226
263
# # Прочее
227
264
228
265
- Пришлось залочить пакет ` psr/container` на версию 1.0. Без этого ставился 1.1.1 (по запросу Symfony DI)
229
266
и конструкция падала из-за несоответствия интерфейсов.
230
267
231
- Последствия: DI компонент пока версии 5.2, а не актуальной 5.3.
268
+ Последствия: DI компонент пока версии 5.2, а не актуальной 5.3.
269
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Local \ComposerScript ;
4
+
5
+ use Composer \Script \Event ;
6
+
7
+ /**
8
+ * Class CacheWarmerHandler
9
+ * @package Local\ComposerScript
10
+ *
11
+ * @since 04.08.2021
12
+ */
13
+ class CacheWarmerHandler
14
+ {
15
+ /**
16
+ * @param Event $event
17
+ *
18
+ * @return void
19
+ */
20
+ public static function doInstall (Event $ event ): void
21
+ {
22
+ $ io = $ event ->getIO ();
23
+
24
+ $ output = shell_exec ('php bin/console cache:clear ' );
25
+ $ io ->write ($ output );
26
+
27
+ $ output = shell_exec ('php bin/console cache:warm ' );
28
+ $ io ->write ($ output );
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Local \ComposerScript ;
4
+
5
+ use Composer \Script \Event ;
6
+
7
+ /**
8
+ * Class RunMigrationsHandler
9
+ * @package Local\ComposerScript
10
+ */
11
+ class RunMigrationsHandler
12
+ {
13
+ /**
14
+ * @param Event $event
15
+ *
16
+ * @return void
17
+ */
18
+ public static function doInstall (Event $ event ): void
19
+ {
20
+ $ io = $ event ->getIO ();
21
+
22
+ $ output = shell_exec ('php migrator migrate ' );
23
+ $ io ->write ($ output );
24
+ }
25
+ }
Original file line number Diff line number Diff line change 26
26
Arrilot \BitrixModels \ServiceProvider::register ();
27
27
Arrilot \BitrixModels \ServiceProvider::registerEloquent ();
28
28
29
+ // Во избежании проблем с созданием кэша на проде
30
+ // @see https://symfony.com/doc/current/setup/file_permissions.html
31
+ umask (0000 );
32
+
29
33
// Symfony сервис-провайдер
30
34
$ symfonyServiceProvider = new ServiceProvider (
31
35
'local/configs/services.yaml '
You can’t perform that action at this time.
0 commit comments