From c3d877a76cbc223439993ee51ddd5f2cd07c7014 Mon Sep 17 00:00:00 2001 From: Alexander Schwenn Date: Mon, 31 Oct 2022 17:54:57 +0100 Subject: [PATCH 1/3] Add paragraph about symfony-cli workers --- setup/symfony_server.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 9dbda5f31de..e06d6315aaf 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -277,6 +277,31 @@ server provides a ``run`` command to wrap them as follows: # stop the web server (and all the associated commands) when you are finished $ symfony server:stop +Configuring Workers +------------------- + +If you like processes to start automatically, along with the webserver +(``symfony server:start``), you can add a configuration file to your project: + +.. code-block:: yaml + + # .symfony.local.yaml + workers: + # pre-defined command to build and watch front-end assets + # yarn_encore_watch: + # cmd: ['yarn', 'encore', 'dev', '--watch'] + yarn_encore_watch: ~ + + # pre-defined command to start messenger consumer + # messenger_consume_async: + # cmd: ['symfony', 'console', 'messenger:consume', 'async'] + # watch: ['config', 'src', 'templates', 'vendor'] + messenger_consume_async: ~ + + # additional commands + spa: + cmd: ['yarn', '--cwd', './spa/', 'dev'] + Docker Integration ------------------ From 4ea004e152ad957773c93e00d2a7bff3281c4bdf Mon Sep 17 00:00:00 2001 From: Romain Monteil Date: Sun, 30 Oct 2022 01:55:53 +0200 Subject: [PATCH 2/3] [Form] Reorder and remove duplicate methods explanation for form type --- form/create_custom_field_type.rst | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index dbca331e050..2998a763445 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -119,13 +119,6 @@ These are the most important methods that a form type class can define: .. _form-type-methods-explanation: -``getParent()`` - When returning a (fully-qualified) class name here, Symfony will call each - method of that type (i.e. ``buildForm()``, ``buildView()``, etc.) and all its - type extensions, before calling the corresponding method of your custom type. - This is probably a good idea if you're just changing some details of an - existing type. To start from scratch, omit ``getParent()``. - ``buildForm()`` It adds and configures other types into this type. It's the same method used when :ref:`creating Symfony form classes `. @@ -133,25 +126,27 @@ These are the most important methods that a form type class can define: ``buildView()`` It sets any extra variables you'll need when rendering the field in a template. -``configureOptions()`` - It defines the options configurable when using the form type, which are also - the options that can be used in ``buildForm()`` and ``buildView()`` - methods. Options are inherited from parent types and parent type - extensions, but you can create any custom option you need. - ``finishView()`` This method allows to modify the "view" of any rendered widget. This is useful if your form type consists of many fields, or contains a type that produces many HTML elements (e.g. ``ChoiceType``). For any other use case, it's recommended to use ``buildView()`` instead. +``configureOptions()`` + It defines the options configurable when using the form type, which are also + the options that can be used in ``buildForm()`` and ``buildView()`` + methods. Options are inherited from parent types and parent type + extensions, but you can create any custom option you need. + ``getParent()`` If your custom type is based on another type (i.e. they share some - functionality) add this method to return the fully-qualified class name + functionality), add this method to return the fully-qualified class name of that original type. Do not use PHP inheritance for this. Symfony will call all the form type methods (``buildForm()``, - ``buildView()``, etc.) of the parent type and it will call all its type - extensions before calling the ones defined in your custom type. + ``buildView()``, etc.) and type extensions of the parent before + calling the ones defined in your custom type. + + Otherwise, if your custom type is build from scratch, you can omit ``getParent()``. By default, the ``AbstractType`` class returns the generic :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` From 4e11720f5697cc85b6d3c8a79c06f827f7a14144 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 3 Nov 2022 16:04:42 +0100 Subject: [PATCH 3/3] Tweaks --- setup/symfony_server.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index e06d6315aaf..8cc8d4dfd75 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -280,26 +280,26 @@ server provides a ``run`` command to wrap them as follows: Configuring Workers ------------------- -If you like processes to start automatically, along with the webserver -(``symfony server:start``), you can add a configuration file to your project: +If you like some processes to start automatically, along with the webserver +(``symfony server:start``), add a configuration file to your project: .. code-block:: yaml # .symfony.local.yaml workers: - # pre-defined command to build and watch front-end assets + # built-in command that builds and watches front-end assets # yarn_encore_watch: # cmd: ['yarn', 'encore', 'dev', '--watch'] yarn_encore_watch: ~ - # pre-defined command to start messenger consumer + # built-in command that starts messenger consumer # messenger_consume_async: # cmd: ['symfony', 'console', 'messenger:consume', 'async'] # watch: ['config', 'src', 'templates', 'vendor'] messenger_consume_async: ~ - # additional commands - spa: + # you can also add your own custom commands + build_spa: cmd: ['yarn', '--cwd', './spa/', 'dev'] Docker Integration