31 |
32 | {% trans %}Free document hosting provided by Read the Docs.{% endtrans %}
33 |
34 |
35 |
36 | {% endif %}
37 |
38 |
--------------------------------------------------------------------------------
/_images/components/console/debug_formatter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/debug_formatter.png
--------------------------------------------------------------------------------
/_images/components/console/process-helper-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/process-helper-debug.png
--------------------------------------------------------------------------------
/_images/components/console/process-helper-error-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/process-helper-error-debug.png
--------------------------------------------------------------------------------
/_images/components/console/process-helper-verbose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/process-helper-verbose.png
--------------------------------------------------------------------------------
/_images/components/console/progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/progress.png
--------------------------------------------------------------------------------
/_images/components/console/progressbar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/console/progressbar.gif
--------------------------------------------------------------------------------
/_images/components/form/general_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/form/general_flow.png
--------------------------------------------------------------------------------
/_images/components/form/set_data_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/form/set_data_flow.png
--------------------------------------------------------------------------------
/_images/components/form/submission_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/form/submission_flow.png
--------------------------------------------------------------------------------
/_images/components/string/bytes-points-graphemes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/string/bytes-points-graphemes.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/01-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/01-simple.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/02-multi-line-str.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/02-multi-line-str.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/03-object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/03-object.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/04-dynamic-property.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/04-dynamic-property.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/05-soft-ref.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/05-soft-ref.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/06-constants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/06-constants.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/07-hard-ref.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/07-hard-ref.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/08-virtual-property.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/08-virtual-property.png
--------------------------------------------------------------------------------
/_images/components/var_dumper/09-cut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/var_dumper/09-cut.png
--------------------------------------------------------------------------------
/_images/components/workflow/blogpost.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/blogpost.png
--------------------------------------------------------------------------------
/_images/components/workflow/blogpost_puml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/blogpost_puml.png
--------------------------------------------------------------------------------
/_images/components/workflow/job_application.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/job_application.png
--------------------------------------------------------------------------------
/_images/components/workflow/pull_request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/pull_request.png
--------------------------------------------------------------------------------
/_images/components/workflow/pull_request_puml_styled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/pull_request_puml_styled.png
--------------------------------------------------------------------------------
/_images/components/workflow/simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/simple.png
--------------------------------------------------------------------------------
/_images/components/workflow/states_transitions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/components/workflow/states_transitions.png
--------------------------------------------------------------------------------
/_images/contributing/docs-github-create-pr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/contributing/docs-github-create-pr.png
--------------------------------------------------------------------------------
/_images/contributing/docs-github-edit-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/contributing/docs-github-edit-page.png
--------------------------------------------------------------------------------
/_images/contributing/docs-pull-request-change-base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/contributing/docs-pull-request-change-base.png
--------------------------------------------------------------------------------
/_images/contributing/docs-pull-request-symfonycloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/contributing/docs-pull-request-symfonycloud.png
--------------------------------------------------------------------------------
/_images/controller/error_pages/errors-in-prod-environment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/controller/error_pages/errors-in-prod-environment.png
--------------------------------------------------------------------------------
/_images/controller/error_pages/exceptions-in-dev-environment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/controller/error_pages/exceptions-in-dev-environment.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-01.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-02.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-03.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-04.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-05.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-06.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-07.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-08.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-09.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-10.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-11.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-12.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-13.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-14.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-15.png
--------------------------------------------------------------------------------
/_images/deployment/azure-website/step-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/deployment/azure-website/step-16.png
--------------------------------------------------------------------------------
/_images/docs-pull-request-change-base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/docs-pull-request-change-base.png
--------------------------------------------------------------------------------
/_images/doctrine/doctrine_web_debug_toolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/doctrine/doctrine_web_debug_toolbar.png
--------------------------------------------------------------------------------
/_images/doctrine/mapping_relations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/doctrine/mapping_relations.png
--------------------------------------------------------------------------------
/_images/doctrine/mapping_relations_proxy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/doctrine/mapping_relations_proxy.png
--------------------------------------------------------------------------------
/_images/doctrine/mapping_single_entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/doctrine/mapping_single_entity.png
--------------------------------------------------------------------------------
/_images/form/data-transformer-types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/form/data-transformer-types.png
--------------------------------------------------------------------------------
/_images/form/simple-form-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/form/simple-form-2.png
--------------------------------------------------------------------------------
/_images/form/simple-form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/form/simple-form.png
--------------------------------------------------------------------------------
/_images/http/xkcd-full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/http/xkcd-full.png
--------------------------------------------------------------------------------
/_images/http/xkcd-request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/http/xkcd-request.png
--------------------------------------------------------------------------------
/_images/install/deprecations-in-profiler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/install/deprecations-in-profiler.png
--------------------------------------------------------------------------------
/_images/mercure/chrome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/mercure/chrome.png
--------------------------------------------------------------------------------
/_images/mercure/discovery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/mercure/discovery.png
--------------------------------------------------------------------------------
/_images/mercure/panel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/mercure/panel.png
--------------------------------------------------------------------------------
/_images/mercure/schema.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/mercure/schema.png
--------------------------------------------------------------------------------
/_images/profiler/web-interface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/profiler/web-interface.png
--------------------------------------------------------------------------------
/_images/quick_tour/no_routes_page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/quick_tour/no_routes_page.png
--------------------------------------------------------------------------------
/_images/quick_tour/web_debug_toolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/quick_tour/web_debug_toolbar.png
--------------------------------------------------------------------------------
/_images/reference/form/choice-example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/reference/form/choice-example1.png
--------------------------------------------------------------------------------
/_images/reference/form/choice-example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/reference/form/choice-example2.png
--------------------------------------------------------------------------------
/_images/reference/form/choice-example3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/reference/form/choice-example3.png
--------------------------------------------------------------------------------
/_images/reference/form/choice-example4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/reference/form/choice-example4.png
--------------------------------------------------------------------------------
/_images/reference/form/choice-example5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/reference/form/choice-example5.png
--------------------------------------------------------------------------------
/_images/release-process.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/release-process.jpg
--------------------------------------------------------------------------------
/_images/security/anonymous_wdt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/security/anonymous_wdt.png
--------------------------------------------------------------------------------
/_images/security/symfony_loggedin_wdt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/security/symfony_loggedin_wdt.png
--------------------------------------------------------------------------------
/_images/sources/README.md:
--------------------------------------------------------------------------------
1 | How to Create Symfony Diagrams
2 | ==============================
3 |
4 | Creating the Diagram
5 | --------------------
6 |
7 | * Use [Dia][1] as the diagramming application;
8 | * Use [PT Sans Narrow][2] as the only font in all diagrams (if possible, use
9 | only the "normal" weight for all contents);
10 | * Use 36pt as the base font size;
11 | * Use 0.10 cm width for lines and shape borders;
12 | * Use the following color palette:
13 | * Text, lines and shape borders: black (#000000)
14 | * Shape backgrounds:
15 | * Grays: dark (#4d4d4d), medium (#b3b3b3), light (#f2f2f2)
16 | * Blue: #b2d4eb
17 | * Red: #ecbec0
18 | * Green: #b2dec7
19 | * Orange: #fddfbb
20 |
21 | In case of doubt, check the existing diagrams or ask to the
22 | [Symfony Documentation Team][3].
23 |
24 | Saving and Exporting the Diagram
25 | --------------------------------
26 |
27 | * Save the original diagram in `*.dia` format in `_images/sources/`;
28 | * Export the diagram to SVG format and save it in `_images/`.
29 |
30 | Including the Diagram in the Symfony Docs
31 | -----------------------------------------
32 |
33 | Use the following snippet to embed the diagram in the docs:
34 |
35 | ```
36 | .. raw:: html
37 |
38 |
39 | ```
40 |
41 | Reasoning
42 | ---------
43 |
44 | * Dia was chosen because it's one of the few applications which are free, open
45 | source and compatible with Linux, macOS and Windows.
46 | * Font, colors and line widths were chosen to be similar to the diagrams used
47 | in the best tech books.
48 |
49 | Troubleshooting
50 | ---------------
51 |
52 | * On some macOS systems, Dia cannot be executed as a regular application and
53 | you must run the following console command instead:
54 | `export DISPLAY=:0 && /Applications/Dia.app/Contents/Resources/bin/dia`
55 |
56 | [1]: http://dia-installer.de/
57 | [2]: https://fonts.google.com/specimen/PT+Sans+Narrow
58 | [3]: https://symfony.com/doc/current/contributing/code/core_team.html
59 |
--------------------------------------------------------------------------------
/_images/sources/components/messenger/overview.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/components/messenger/overview.dia
--------------------------------------------------------------------------------
/_images/sources/components/serializer/serializer_workflow.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/components/serializer/serializer_workflow.dia
--------------------------------------------------------------------------------
/_images/sources/form/form-custom-type-postal-address-fragment-names.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/form/form-custom-type-postal-address-fragment-names.dia
--------------------------------------------------------------------------------
/_images/sources/form/form-custom-type-postal-address.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/form/form-custom-type-postal-address.dia
--------------------------------------------------------------------------------
/_images/sources/form/form-field-parts.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/form/form-field-parts.dia
--------------------------------------------------------------------------------
/_images/sources/http/request-flow.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/http/request-flow.dia
--------------------------------------------------------------------------------
/_images/sources/http_kernel/http-workflow.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/http_kernel/http-workflow.dia
--------------------------------------------------------------------------------
/_images/sources/security/authentication-guard-methods.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabpot/symfony-docs/9d10a79db2d22fe46f780fa0abb42e81726af602/_images/sources/security/authentication-guard-methods.dia
--------------------------------------------------------------------------------
/_includes/_annotation_loader_tip.rst.inc:
--------------------------------------------------------------------------------
1 | .. note::
2 |
3 | In order to use the annotation loader, you should have installed the
4 | ``doctrine/annotations`` and ``doctrine/cache`` packages with Composer.
5 |
6 | .. tip::
7 |
8 | Annotation classes aren't loaded automatically, so you must load them
9 | using a class loader like this::
10 |
11 | use Composer\Autoload\ClassLoader;
12 | use Doctrine\Common\Annotations\AnnotationRegistry;
13 |
14 | /** @var ClassLoader $loader */
15 | $loader = require __DIR__.'/../vendor/autoload.php';
16 |
17 | AnnotationRegistry::registerLoader([$loader, 'loadClass']);
18 |
19 | return $loader;
20 |
--------------------------------------------------------------------------------
/_includes/_rewrite_rule_tip.rst.inc:
--------------------------------------------------------------------------------
1 | .. tip::
2 |
3 | By using rewrite rules in your
4 | :doc:`web server configuration `,
5 | the ``index.php`` won't be needed and you will have beautiful, clean URLs
6 | (e.g. ``/show``).
7 |
--------------------------------------------------------------------------------
/_includes/service_container/_my_mailer.rst.inc:
--------------------------------------------------------------------------------
1 | .. configuration-block::
2 |
3 | .. code-block:: yaml
4 |
5 | # config/services.yaml
6 | services:
7 | app.mailer:
8 | class: App\Mailer
9 | arguments: [sendmail]
10 |
11 | .. code-block:: xml
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 | sendmail
23 |
24 |
25 |
26 |
27 | .. code-block:: php
28 |
29 | // config/services.php
30 | use App\Mailer;
31 |
32 | $container->register('app.mailer', Mailer::class)
33 | ->addArgument('sendmail');
34 |
--------------------------------------------------------------------------------
/bundles/index.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | Bundles
4 | =======
5 |
6 | .. toctree::
7 | :maxdepth: 2
8 |
9 | override
10 | best_practices
11 | configuration
12 | extension
13 | prepend_extension
14 |
--------------------------------------------------------------------------------
/components/cache/adapters/apcu_adapter.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache Pool
3 | single: APCu Cache
4 |
5 | .. _apcu-adapter:
6 |
7 | APCu Cache Adapter
8 | ==================
9 |
10 | This adapter is a high-performance, shared memory cache. It can *significantly*
11 | increase an application's performance, as its cache contents are stored in shared
12 | memory, a component appreciably faster than many others, such as the filesystem.
13 |
14 | .. caution::
15 |
16 | **Requirement:** The `APCu extension`_ must be installed and active to use
17 | this adapter.
18 |
19 | The ApcuAdapter can optionally be provided a namespace, default cache lifetime,
20 | and cache items version string as constructor arguments::
21 |
22 | use Symfony\Component\Cache\Adapter\ApcuAdapter;
23 |
24 | $cache = new ApcuAdapter(
25 |
26 | // a string prefixed to the keys of the items stored in this cache
27 | $namespace = '',
28 |
29 | // the default lifetime (in seconds) for cache items that do not define their
30 | // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
31 | // until the APCu memory is cleared)
32 | $defaultLifetime = 0,
33 |
34 | // when set, all keys prefixed by $namespace can be invalidated by changing
35 | // this $version string
36 | $version = null
37 | );
38 |
39 | .. caution::
40 |
41 | Use of this adapter is discouraged in write/delete heavy workloads, as these
42 | operations cause memory fragmentation that results in significantly degraded performance.
43 |
44 | .. tip::
45 |
46 | This adapter's CRUD operations are specific to the PHP SAPI it is running under. This
47 | means cache operations (such as additions, deletions, etc) using the CLI will not be
48 | available under the FPM or CGI SAPIs.
49 |
50 | .. _`APCu extension`: https://pecl.php.net/package/APCu
51 |
--------------------------------------------------------------------------------
/components/cache/adapters/array_cache_adapter.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache Pool
3 | single: Array Cache
4 |
5 | Array Cache Adapter
6 | ===================
7 |
8 | Generally, this adapter is useful for testing purposes, as its contents are stored in memory
9 | and not persisted outside the running PHP process in any way. It can also be useful while
10 | warming up caches, due to the :method:`Symfony\\Component\\Cache\\Adapter\\ArrayAdapter::getValues`
11 | method::
12 |
13 | use Symfony\Component\Cache\Adapter\ArrayAdapter;
14 |
15 | $cache = new ArrayAdapter(
16 |
17 | // the default lifetime (in seconds) for cache items that do not define their
18 | // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
19 | // until the current PHP process finishes)
20 | $defaultLifetime = 0,
21 |
22 | // if ``true``, the values saved in the cache are serialized before storing them
23 | $storeSerialized = true,
24 |
25 | // the maximum lifetime (in seconds) of the entire cache (after this time, the
26 | // entire cache is deleted to avoid stale data from consuming memory)
27 | $maxLifetime = 0,
28 |
29 | // the maximum number of items that can be stored in the cache. When the limit
30 | // is reached, cache follows the LRU model (least recently used items are deleted)
31 | $maxItems = 0
32 | );
33 |
34 | .. versionadded:: 5.1
35 |
36 | The ``maxLifetime`` and ``maxItems`` options were introduced in Symfony 5.1.
37 |
--------------------------------------------------------------------------------
/components/cache/adapters/doctrine_adapter.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache Pool
3 | single: Doctrine Cache
4 |
5 | .. _doctrine-adapter:
6 |
7 | Doctrine Cache Adapter
8 | ======================
9 |
10 | This adapter wraps any class extending the `Doctrine Cache`_ abstract provider, allowing
11 | you to use these providers in your application as if they were Symfony Cache adapters.
12 |
13 | This adapter expects a ``\Doctrine\Common\Cache\CacheProvider`` instance as its first
14 | parameter, and optionally a namespace and default cache lifetime as its second and
15 | third parameters::
16 |
17 | use Doctrine\Common\Cache\CacheProvider;
18 | use Doctrine\Common\Cache\SQLite3Cache;
19 | use Symfony\Component\Cache\Adapter\DoctrineAdapter;
20 |
21 | $provider = new SQLite3Cache(new \SQLite3(__DIR__.'/cache/data.sqlite'), 'youTableName');
22 |
23 | $cache = new DoctrineAdapter(
24 |
25 | // a cache provider instance
26 | CacheProvider $provider,
27 |
28 | // a string prefixed to the keys of the items stored in this cache
29 | $namespace = '',
30 |
31 | // the default lifetime (in seconds) for cache items that do not define their
32 | // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
33 | // until the database table is truncated or its rows are otherwise deleted)
34 | $defaultLifetime = 0
35 | );
36 |
37 | .. tip::
38 |
39 | A :class:`Symfony\\Component\\Cache\\DoctrineProvider` class is also provided by the
40 | component to use any PSR6-compatible implementations with Doctrine-compatible classes.
41 |
42 | .. _`Doctrine Cache`: https://github.com/doctrine/cache
43 |
--------------------------------------------------------------------------------
/components/cache/adapters/php_array_cache_adapter.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache Pool
3 | single: PHP Array Cache
4 |
5 | PHP Array Cache Adapter
6 | =======================
7 |
8 | This adapter is a high performance cache for static data (e.g. application configuration)
9 | that is optimized and preloaded into OPcache memory storage. It is suited for any data that
10 | is mostly read-only after warmup::
11 |
12 | use Symfony\Component\Cache\Adapter\FilesystemAdapter;
13 | use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
14 |
15 | // somehow, decide it's time to warm up the cache!
16 | if ($needsWarmup) {
17 | // some static values
18 | $values = [
19 | 'stats.products_count' => 4711,
20 | 'stats.users_count' => 1356,
21 | ];
22 |
23 | $cache = new PhpArrayAdapter(
24 | // single file where values are cached
25 | __DIR__ . '/somefile.cache',
26 | // a backup adapter, if you set values after warmup
27 | new FilesystemAdapter()
28 | );
29 | $cache->warmUp($values);
30 | }
31 |
32 | // ... then, use the cache!
33 | $cacheItem = $cache->getItem('stats.users_count');
34 | echo $cacheItem->get();
35 |
36 | .. note::
37 |
38 | This adapter requires turning on the ``opcache.enable`` php.ini setting.
39 |
--------------------------------------------------------------------------------
/components/cache/adapters/proxy_adapter.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache Pool
3 | single: Proxy Cache
4 |
5 | Proxy Cache Adapter
6 | ===================
7 |
8 | This adapter wraps a `PSR-6`_ compliant `cache item pool interface`_. It is used to integrate
9 | your application's cache item pool implementation with the Symfony :ref:`Cache Component `
10 | by consuming any implementation of ``Psr\Cache\CacheItemPoolInterface``.
11 |
12 | It can also be used to prefix all keys automatically before storing items in the decorated pool,
13 | effectively allowing the creation of several namespaced pools out of a single one.
14 |
15 | This adapter expects a ``Psr\Cache\CacheItemPoolInterface`` instance as its first parameter,
16 | and optionally a namespace and default cache lifetime as its second and third parameters::
17 |
18 | use Psr\Cache\CacheItemPoolInterface;
19 | use Symfony\Component\Cache\Adapter\ProxyAdapter;
20 |
21 | // create your own cache pool instance that implements
22 | // the PSR-6 CacheItemPoolInterface
23 | $psr6CachePool = ...
24 |
25 | $cache = new ProxyAdapter(
26 |
27 | // a cache pool instance
28 | CacheItemPoolInterface $psr6CachePool,
29 |
30 | // a string prefixed to the keys of the items stored in this cache
31 | $namespace = '',
32 |
33 | // the default lifetime (in seconds) for cache items that do not define their
34 | // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
35 | // until the cache is cleared)
36 | $defaultLifetime = 0
37 | );
38 |
39 | .. _`PSR-6`: https://www.php-fig.org/psr/psr-6/
40 | .. _`cache item pool interface`: https://www.php-fig.org/psr/psr-6/#cacheitempoolinterface
41 |
--------------------------------------------------------------------------------
/components/config.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Config
3 | single: Components; Config
4 |
5 | The Config Component
6 | ====================
7 |
8 | The Config component provides several classes to help you find, load,
9 | combine, fill and validate configuration values of any kind, whatever
10 | their source may be (YAML, XML, INI files, or for instance a database).
11 |
12 | Installation
13 | ------------
14 |
15 | .. code-block:: terminal
16 |
17 | $ composer require symfony/config
18 |
19 | .. include:: /components/require_autoload.rst.inc
20 |
21 | Learn More
22 | ----------
23 |
24 | .. toctree::
25 | :maxdepth: 1
26 | :glob:
27 |
28 | config/*
29 | /bundles/configuration
30 | /bundles/extension
31 | /bundles/prepend_extension
32 |
--------------------------------------------------------------------------------
/components/console.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Console; CLI
3 | single: Components; Console
4 |
5 | The Console Component
6 | =====================
7 |
8 | The Console component eases the creation of beautiful and testable command
9 | line interfaces.
10 |
11 | The Console component allows you to create command-line commands. Your console
12 | commands can be used for any recurring task, such as cronjobs, imports, or
13 | other batch jobs.
14 |
15 | Installation
16 | ------------
17 |
18 | .. code-block:: terminal
19 |
20 | $ composer require symfony/console
21 |
22 | .. include:: /components/require_autoload.rst.inc
23 |
24 | Creating a Console Application
25 | ------------------------------
26 |
27 | .. seealso::
28 |
29 | This article explains how to use the Console features as an independent
30 | component in any PHP application. Read the :doc:`/console` article to
31 | learn about how to use it in Symfony applications.
32 |
33 | First, you need to create a PHP script to define the console application::
34 |
35 | #!/usr/bin/env php
36 | run();
48 |
49 | Then, you can register the commands using
50 | :method:`Symfony\\Component\\Console\\Application::add`::
51 |
52 | // ...
53 | $application->add(new GenerateAdminCommand());
54 |
55 | See the :doc:`/console` article for information about how to create commands.
56 |
57 | Learn more
58 | ----------
59 |
60 | .. toctree::
61 | :maxdepth: 1
62 | :glob:
63 |
64 | /console
65 | /components/console/*
66 | /components/console/helpers/index
67 | /console/*
68 |
--------------------------------------------------------------------------------
/components/console/changing_default_command.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Console; Changing the Default Command
3 |
4 | Changing the Default Command
5 | ============================
6 |
7 | The Console component will always run the ``ListCommand`` when no command name is
8 | passed. In order to change the default command you need to pass the command
9 | name to the ``setDefaultCommand()`` method::
10 |
11 | namespace Acme\Console\Command;
12 |
13 | use Symfony\Component\Console\Command\Command;
14 | use Symfony\Component\Console\Input\InputInterface;
15 | use Symfony\Component\Console\Output\OutputInterface;
16 |
17 | class HelloWorldCommand extends Command
18 | {
19 | protected static $defaultName = 'hello:world';
20 |
21 | protected function configure()
22 | {
23 | $this->setDescription('Outputs "Hello World"');
24 | }
25 |
26 | protected function execute(InputInterface $input, OutputInterface $output)
27 | {
28 | $output->writeln('Hello World');
29 | }
30 | }
31 |
32 | Executing the application and changing the default command::
33 |
34 | // application.php
35 | use Acme\Console\Command\HelloWorldCommand;
36 | use Symfony\Component\Console\Application;
37 |
38 | $command = new HelloWorldCommand();
39 | $application = new Application();
40 | $application->add($command);
41 | $application->setDefaultCommand($command->getName());
42 | $application->run();
43 |
44 | Test the new default console command by running the following:
45 |
46 | .. code-block:: terminal
47 |
48 | $ php application.php
49 |
50 | This will print the following to the command line:
51 |
52 | .. code-block:: text
53 |
54 | Hello World
55 |
56 | .. caution::
57 |
58 | This feature has a limitation: you cannot pass any argument or option to
59 | the default command because they are ignored.
60 |
61 | Learn More!
62 | -----------
63 |
64 | * :doc:`/components/console/single_command_tool`
65 |
--------------------------------------------------------------------------------
/components/console/helpers/index.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Console; Console Helpers
3 |
4 | The Console Helpers
5 | ===================
6 |
7 | .. toctree::
8 | :hidden:
9 |
10 | formatterhelper
11 | processhelper
12 | progressbar
13 | questionhelper
14 | table
15 | debug_formatter
16 |
17 | The Console component comes with some useful helpers. These helpers contain
18 | function to ease some common tasks.
19 |
20 | .. include:: map.rst.inc
21 |
--------------------------------------------------------------------------------
/components/console/helpers/map.rst.inc:
--------------------------------------------------------------------------------
1 | * :doc:`/components/console/helpers/formatterhelper`
2 | * :doc:`/components/console/helpers/processhelper`
3 | * :doc:`/components/console/helpers/progressbar`
4 | * :doc:`/components/console/helpers/questionhelper`
5 | * :doc:`/components/console/helpers/table`
6 | * :doc:`/components/console/helpers/debug_formatter`
7 |
--------------------------------------------------------------------------------
/components/console/single_command_tool.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Console; Single command application
3 |
4 | Building a single Command Application
5 | =====================================
6 |
7 | When building a command line tool, you may not need to provide several commands.
8 | In such case, having to pass the command name each time is tedious.
9 |
10 | .. versionadded:: 5.1
11 |
12 | The :class:`Symfony\\Component\\Console\\SingleCommandApplication` class was
13 | introduced in Symfony 5.1.
14 |
15 | Fortunately, it is possible to remove this need by declaring a single command
16 | application::
17 |
18 | #!/usr/bin/env php
19 | setName('My Super Command') // Optional
30 | ->setVersion('1.0.0') // Optional
31 | ->addArgument('foo', InputArgument::OPTIONAL, 'The directory')
32 | ->addOption('bar', null, InputOption::VALUE_REQUIRED)
33 | ->setCode(function (InputInterface $input, OutputInterface $output) {
34 | // output arguments and options
35 | })
36 | ->run();
37 |
38 | You can still register a command as usual::
39 |
40 | #!/usr/bin/env php
41 | add($command);
51 |
52 | $application->setDefaultCommand($command->getName(), true);
53 | $application->run();
54 |
55 | The :method:`Symfony\\Component\\Console\\Application::setDefaultCommand` method
56 | accepts a boolean as second parameter. If true, the command ``echo`` will then
57 | always be used, without having to pass its name.
58 |
--------------------------------------------------------------------------------
/components/dependency_injection/_imports-parameters-note.rst.inc:
--------------------------------------------------------------------------------
1 | .. note::
2 |
3 | Due to the way in which parameters are resolved, you cannot use them
4 | to build paths in imports dynamically. This means that something like
5 | the following doesn't work:
6 |
7 | .. configuration-block::
8 |
9 | .. code-block:: yaml
10 |
11 | # config/services.yaml
12 | imports:
13 | - { resource: '%kernel.project_dir%/somefile.yaml' }
14 |
15 | .. code-block:: xml
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | .. code-block:: php
30 |
31 | // config/services.php
32 | $loader->import('%kernel.project_dir%/somefile.yaml');
33 |
--------------------------------------------------------------------------------
/components/event_dispatcher/container_aware_dispatcher.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: EventDispatcher; Service container aware
3 |
4 | The Container Aware Event Dispatcher
5 | ====================================
6 |
7 | .. caution::
8 |
9 | The ``ContainerAwareEventDispatcher`` was removed in Symfony 4.0. Use
10 | ``EventDispatcher`` with closure-proxy injection instead.
11 |
--------------------------------------------------------------------------------
/components/event_dispatcher/immutable_dispatcher.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: EventDispatcher; Immutable
3 |
4 | The Immutable Event Dispatcher
5 | ==============================
6 |
7 | The :class:`Symfony\\Component\\EventDispatcher\\ImmutableEventDispatcher`
8 | is a locked or frozen event dispatcher. The dispatcher cannot register new
9 | listeners or subscribers.
10 |
11 | The ``ImmutableEventDispatcher`` takes another event dispatcher with all
12 | the listeners and subscribers. The immutable dispatcher is just a proxy
13 | of this original dispatcher.
14 |
15 | To use it, first create a normal ``EventDispatcher`` dispatcher and register
16 | some listeners or subscribers::
17 |
18 | use Symfony\Component\EventDispatcher\EventDispatcher;
19 |
20 | $dispatcher = new EventDispatcher();
21 | $dispatcher->addListener('foo.action', function ($event) {
22 | // ...
23 | });
24 |
25 | // ...
26 |
27 | Now, inject that into an ``ImmutableEventDispatcher``::
28 |
29 | use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
30 | // ...
31 |
32 | $immutableDispatcher = new ImmutableEventDispatcher($dispatcher);
33 |
34 | You'll need to use this new dispatcher in your project.
35 |
36 | If you are trying to execute one of the methods which modifies the dispatcher
37 | (e.g. ``addListener()``), a ``BadMethodCallException`` is thrown.
38 |
--------------------------------------------------------------------------------
/components/event_dispatcher/traceable_dispatcher.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: EventDispatcher; Debug
3 | single: EventDispatcher; Traceable
4 |
5 | The Traceable Event Dispatcher
6 | ==============================
7 |
8 | The :class:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher`
9 | is an event dispatcher that wraps any other event dispatcher and can then
10 | be used to determine which event listeners have been called by the dispatcher.
11 | Pass the event dispatcher to be wrapped and an instance of the
12 | :class:`Symfony\\Component\\Stopwatch\\Stopwatch` to its constructor::
13 |
14 | use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
15 | use Symfony\Component\Stopwatch\Stopwatch;
16 |
17 | // the event dispatcher to debug
18 | $dispatcher = ...;
19 |
20 | $traceableEventDispatcher = new TraceableEventDispatcher(
21 | $dispatcher,
22 | new Stopwatch()
23 | );
24 |
25 | Now, the ``TraceableEventDispatcher`` can be used like any other event dispatcher
26 | to register event listeners and dispatch events::
27 |
28 | // ...
29 |
30 | // registers an event listener
31 | $eventListener = ...;
32 | $priority = ...;
33 | $traceableEventDispatcher->addListener(
34 | 'event.the_name',
35 | $eventListener,
36 | $priority
37 | );
38 |
39 | // dispatches an event
40 | $event = ...;
41 | $traceableEventDispatcher->dispatch($event, 'event.the_name');
42 |
43 | After your application has been processed, you can use the
44 | :method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getCalledListeners`
45 | method to retrieve an array of event listeners that have been called in
46 | your application. Similarly, the
47 | :method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getNotCalledListeners`
48 | method returns an array of event listeners that have not been called::
49 |
50 | // ...
51 |
52 | $calledListeners = $traceableEventDispatcher->getCalledListeners();
53 | $notCalledListeners = $traceableEventDispatcher->getNotCalledListeners();
54 |
--------------------------------------------------------------------------------
/components/expression_language/ast.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: AST; ExpressionLanguage
3 | single: AST; Abstract Syntax Tree
4 |
5 | Dumping and Manipulating the AST of Expressions
6 | ===============================================
7 |
8 | Manipulating or inspecting the expressions created with the ExpressionLanguage
9 | component is difficult because they are plain strings. A better approach is to
10 | turn those expressions into an AST. In computer science, `AST`_ (*Abstract
11 | Syntax Tree*) is *"a tree representation of the structure of source code written
12 | in a programming language"*. In Symfony, a ExpressionLanguage AST is a set of
13 | nodes that contain PHP classes representing the given expression.
14 |
15 | Dumping the AST
16 | ---------------
17 |
18 | Call the :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::getNodes`
19 | method after parsing any expression to get its AST::
20 |
21 | use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
22 |
23 | $ast = (new ExpressionLanguage())
24 | ->parse('1 + 2', [])
25 | ->getNodes()
26 | ;
27 |
28 | // dump the AST nodes for inspection
29 | var_dump($ast);
30 |
31 | // dump the AST nodes as a string representation
32 | $astAsString = $ast->dump();
33 |
34 | Manipulating the AST
35 | --------------------
36 |
37 | The nodes of the AST can also be dumped into a PHP array of nodes to allow
38 | manipulating them. Call the :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::toArray`
39 | method to turn the AST into an array::
40 |
41 | // ...
42 |
43 | $astAsArray = (new ExpressionLanguage())
44 | ->parse('1 + 2', [])
45 | ->getNodes()
46 | ->toArray()
47 | ;
48 |
49 | .. _`AST`: https://en.wikipedia.org/wiki/Abstract_syntax_tree
50 |
--------------------------------------------------------------------------------
/components/filesystem/lock_handler.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | LockHandler
4 | ===========
5 |
6 | .. caution::
7 |
8 | The ``LockHandler`` utility was removed in Symfony 4.0. Use the new Symfony
9 | :doc:`Lock component ` instead.
10 |
--------------------------------------------------------------------------------
/components/http_foundation/session_php_bridge.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: HTTP
3 | single: HttpFoundation, Sessions
4 |
5 | Integrating with Legacy Sessions
6 | ================================
7 |
8 | Sometimes it may be necessary to integrate Symfony into a legacy application
9 | where you do not initially have the level of control you require.
10 |
11 | As stated elsewhere, Symfony Sessions are designed to replace the use of
12 | PHP's native ``session_*()`` functions and use of the ``$_SESSION``
13 | superglobal. Additionally, it is mandatory for Symfony to start the session.
14 |
15 | However, when there really are circumstances where this is not possible, you
16 | can use a special storage bridge
17 | :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage`
18 | which is designed to allow Symfony to work with a session started outside of
19 | the Symfony HttpFoundation component. You are warned that things can interrupt
20 | this use-case unless you are careful: for example the legacy application
21 | erases ``$_SESSION``.
22 |
23 | A typical use of this might look like this::
24 |
25 | use Symfony\Component\HttpFoundation\Session\Session;
26 | use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
27 |
28 | // legacy application configures session
29 | ini_set('session.save_handler', 'files');
30 | ini_set('session.save_path', '/tmp');
31 | session_start();
32 |
33 | // Get Symfony to interface with this existing session
34 | $session = new Session(new PhpBridgeSessionStorage());
35 |
36 | // symfony will now interface with the existing PHP session
37 | $session->start();
38 |
39 | This will allow you to start using the Symfony Session API and allow migration
40 | of your application to Symfony sessions.
41 |
42 | .. note::
43 |
44 | Symfony sessions store data like attributes in special 'Bags' which use a
45 | key in the ``$_SESSION`` superglobal. This means that a Symfony session
46 | cannot access arbitrary keys in ``$_SESSION`` that may be set by the legacy
47 | application, although all the ``$_SESSION`` contents will be saved when
48 | the session is saved.
49 |
--------------------------------------------------------------------------------
/components/index.rst:
--------------------------------------------------------------------------------
1 | The Components
2 | ==============
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 | :glob:
7 |
8 | using_components
9 | *
10 |
--------------------------------------------------------------------------------
/components/inflector.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Inflector
3 | single: Components; Inflector
4 |
5 | The Inflector Component
6 | =======================
7 |
8 | .. deprecated:: 5.1
9 |
10 | The Inflector component was deprecated in Symfony 5.1 and its code was moved
11 | into the :doc:`String ` component.
12 | :ref:`Read the new Inflector docs `.
13 |
--------------------------------------------------------------------------------
/components/require_autoload.rst.inc:
--------------------------------------------------------------------------------
1 | .. note::
2 |
3 | If you install this component outside of a Symfony application, you must
4 | require the ``vendor/autoload.php`` file in your code to enable the class
5 | autoloading mechanism provided by Composer. Read
6 | :doc:`this article ` for more details.
7 |
--------------------------------------------------------------------------------
/console/hide_commands.rst:
--------------------------------------------------------------------------------
1 | How to Hide Console Commands
2 | ============================
3 |
4 | By default, all console commands are listed when executing the console application
5 | script without arguments or when using the ``list`` command.
6 |
7 | However, sometimes commands are not intended to be executed by end-users; for
8 | example, commands for the legacy parts of the application, commands exclusively
9 | executed through scheduled tasks, etc.
10 |
11 | In those cases, you can define the command as **hidden** by setting the
12 | ``setHidden()`` method to ``true`` in the command configuration::
13 |
14 | // src/Command/LegacyCommand.php
15 | namespace App\Command;
16 |
17 | use Symfony\Component\Console\Command\Command;
18 |
19 | class LegacyCommand extends Command
20 | {
21 | protected static $defaultName = 'app:legacy';
22 |
23 | protected function configure()
24 | {
25 | $this
26 | ->setHidden(true)
27 | // ...
28 | ;
29 | }
30 | }
31 |
32 | Hidden commands behave the same as normal commands but they are no longer displayed
33 | in command listings, so end-users are not aware of their existence.
34 |
35 | .. note::
36 |
37 | Hidden commands are still available using the JSON or XML descriptor.
38 |
--------------------------------------------------------------------------------
/console/lockable_trait.rst:
--------------------------------------------------------------------------------
1 | Prevent Multiple Executions of a Console Command
2 | ================================================
3 |
4 | A simple but effective way to prevent multiple executions of the same command in
5 | a single server is to use `locks`_. The :doc:`Lock component `
6 | provides multiple classes to create locks based on the filesystem (:ref:`FlockStore `),
7 | shared memory (:ref:`SemaphoreStore `) and even databases
8 | and Redis servers.
9 |
10 | In addition, the Console component provides a PHP trait called ``LockableTrait``
11 | that adds two convenient methods to lock and release commands::
12 |
13 | // ...
14 | use Symfony\Component\Console\Command\Command;
15 | use Symfony\Component\Console\Command\LockableTrait;
16 | use Symfony\Component\Console\Input\InputInterface;
17 | use Symfony\Component\Console\Output\OutputInterface;
18 |
19 | class UpdateContentsCommand extends Command
20 | {
21 | use LockableTrait;
22 |
23 | // ...
24 |
25 | protected function execute(InputInterface $input, OutputInterface $output)
26 | {
27 | if (!$this->lock()) {
28 | $output->writeln('The command is already running in another process.');
29 |
30 | return Command::SUCCESS;
31 | }
32 |
33 | // If you prefer to wait until the lock is released, use this:
34 | // $this->lock(null, true);
35 |
36 | // ...
37 |
38 | // if not released explicitly, Symfony releases the lock
39 | // automatically when the execution of the command ends
40 | $this->release();
41 | }
42 | }
43 |
44 | .. versionadded:: 5.1
45 |
46 | The ``Command::SUCCESS`` constant was introduced in Symfony 5.1.
47 |
48 | .. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science)
49 |
--------------------------------------------------------------------------------
/contributing/code/experimental.rst:
--------------------------------------------------------------------------------
1 | Experimental Features
2 | =====================
3 |
4 | All Symfony features benefit from our :doc:`Backward Compatibility Promise
5 | ` to give developers the confidence to upgrade to new
6 | versions safely and more often.
7 |
8 | But sometimes, a new feature is controversial or you cannot find a convincing API.
9 | In such cases, we prefer to gather feedback from real-world usage, adapt
10 | the API, or remove it altogether. Doing so is not possible with a no BC-break
11 | approach.
12 |
13 | To avoid being bound to our backward compatibility promise, such features can
14 | be marked as **experimental** and their classes and methods must be marked with
15 | the ``@experimental`` tag.
16 |
17 | A feature can be marked as being experimental for only one minor version, and
18 | can never be introduced in an :ref:`LTS version `. The core team
19 | can decide to extend the experimental period for another minor version on a
20 | case by case basis.
21 |
22 | To ease upgrading projects using experimental features, the changelog must
23 | explain backward incompatible changes and explain how to upgrade code.
24 |
--------------------------------------------------------------------------------
/contributing/code/git.rst:
--------------------------------------------------------------------------------
1 | Git
2 | ===
3 |
4 | This document explains some conventions and specificities in the way we manage
5 | the Symfony code with Git.
6 |
7 | Pull Requests
8 | -------------
9 |
10 | Whenever a pull request is merged, all the information contained in the pull
11 | request (including comments) is saved in the repository.
12 |
13 | You can identify pull request merges as the commit message always follows
14 | this pattern:
15 |
16 | .. code-block:: text
17 |
18 | merged branch USER_NAME/BRANCH_NAME (PR #1111)
19 |
20 | The PR reference allows you to have a look at the original pull request on
21 | GitHub: https://github.com/symfony/symfony/pull/1111. But all the information
22 | you can get on GitHub is also available from the repository itself.
23 |
24 | The merge commit message contains the original message from the author of the
25 | changes. Often, this can help understand what the changes were about and the
26 | reasoning behind the changes.
27 |
28 | Moreover, the full discussion that might have occurred back then is also
29 | stored as a Git note (before March 22 2013, the discussion was part of the
30 | main merge commit message). To get access to these notes, add this line to
31 | your ``.git/config`` file:
32 |
33 | .. code-block:: ini
34 |
35 | fetch = +refs/notes/*:refs/notes/*
36 |
37 | After a fetch, getting the GitHub discussion for a commit is then a matter of
38 | adding ``--show-notes=github-comments`` to the ``git show`` command:
39 |
40 | .. code-block:: terminal
41 |
42 | $ git show HEAD --show-notes=github-comments
43 |
--------------------------------------------------------------------------------
/contributing/code/index.rst:
--------------------------------------------------------------------------------
1 | Contributing Code
2 | =================
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | bugs
8 | reproducer
9 | pull_requests
10 | maintenance
11 | core_team
12 | security
13 | tests
14 | bc
15 | experimental
16 | standards
17 | conventions
18 | git
19 | license
20 |
--------------------------------------------------------------------------------
/contributing/code/license.rst:
--------------------------------------------------------------------------------
1 | .. _symfony2-license:
2 |
3 | Symfony Code License
4 | ====================
5 |
6 | Symfony code is released under `the MIT license`_:
7 |
8 | Copyright (c) 2004-2020 Fabien Potencier
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is furnished
15 | to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.
27 |
28 | Other Symfony Licenses
29 | ----------------------
30 |
31 | Check out the :doc:`license of the Symfony documentation `
32 | and other `Symfony licenses and trademarks`_.
33 |
34 | .. _`the MIT license`: https://en.wikipedia.org/wiki/MIT_License
35 | .. _`Symfony licenses and trademarks`: https://symfony.com/license
36 |
--------------------------------------------------------------------------------
/contributing/code/tests.rst:
--------------------------------------------------------------------------------
1 | .. _running-symfony2-tests:
2 |
3 | Running Symfony Tests
4 | =====================
5 |
6 | The Symfony project uses a third-party service which automatically runs tests
7 | for any submitted :doc:`patch `. If the new code breaks any test,
8 | the pull request will show an error message with a link to the full error details.
9 |
10 | In any case, it's a good practice to run tests locally before submitting a
11 | :doc:`patch ` for inclusion, to check that you have not broken anything.
12 |
13 | .. _phpunit:
14 | .. _dependencies_optional:
15 |
16 | Before Running the Tests
17 | ------------------------
18 |
19 | To run the Symfony test suite, install the external dependencies used during the
20 | tests, such as Doctrine, Twig and Monolog. To do so,
21 | `install Composer`_ and execute the following:
22 |
23 | .. code-block:: terminal
24 |
25 | $ composer update
26 |
27 | .. _running:
28 |
29 | Running the Tests
30 | -----------------
31 |
32 | Then, run the test suite from the Symfony root directory with the following
33 | command:
34 |
35 | .. code-block:: terminal
36 |
37 | $ php ./phpunit symfony
38 |
39 | The output should display ``OK``. If not, read the reported errors to figure out
40 | what's going on and if the tests are broken because of the new code.
41 |
42 | .. tip::
43 |
44 | The entire Symfony suite can take up to several minutes to complete. If you
45 | want to test a single component, type its path after the ``phpunit`` command,
46 | e.g.:
47 |
48 | .. code-block:: terminal
49 |
50 | $ php ./phpunit src/Symfony/Component/Finder/
51 |
52 | .. tip::
53 |
54 | On Windows, install the `Cmder`_, `ConEmu`_, `ANSICON`_ or `Mintty`_ free applications
55 | to see colored test results.
56 |
57 | .. _`install Composer`: https://getcomposer.org/download/
58 | .. _Cmder: https://cmder.net/
59 | .. _ConEmu: https://conemu.github.io/
60 | .. _ANSICON: https://github.com/adoxa/ansicon/releases
61 | .. _Mintty: https://mintty.github.io/
62 |
--------------------------------------------------------------------------------
/contributing/code_of_conduct/concrete_example_document.rst:
--------------------------------------------------------------------------------
1 | Code of Conduct: Concrete Example Document
2 | ==========================================
3 |
4 | This is a living document that serves to give concrete examples of
5 | unwanted behavior. These examples have all taken place somewhere in the
6 | PHP community in the past, and are clear code of conduct violations
7 | according to the Symfony code of conduct.
8 |
9 | Concrete Examples
10 | -----------------
11 |
12 | * Unwelcome comments regarding a person’s lifestyle choices and practices,
13 | including those related to food, health, parenting, drugs, and employment;
14 | * Deliberate misgendering or use of `dead names`_ (The birth name
15 | of a person who has since changed their name, often a transgender person);
16 | * Threats of violence like "The person that created this PR should be
17 | punched in the face";
18 | * Incitement of violence towards any individual, including encouraging a
19 | person to commit suicide or to engage in self-harm (even as a joke);
20 | * Sustained disruption of discussion;
21 | * Pattern of inappropriate social contact, such as requesting/assuming
22 | inappropriate levels of intimacy with others;
23 | * Continued one-on-one communication after requests to cease;
24 | * Putting down people based on their technology choices or their work.
25 |
26 | The original list is inspired and modified from `geek feminism`_ and
27 | confirmed by experiences from PHPWomen.
28 |
29 | .. _dead names: https://en.wiktionary.org/wiki/deadname
30 | .. _geek feminism: https://geekfeminism.org/about/code-of-conduct
31 |
--------------------------------------------------------------------------------
/contributing/code_of_conduct/index.rst:
--------------------------------------------------------------------------------
1 | Code of Conduct
2 | ===============
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | code_of_conduct
8 | reporting_guidelines
9 | care_team
10 | concrete_example_document
11 |
--------------------------------------------------------------------------------
/contributing/community/index.rst:
--------------------------------------------------------------------------------
1 | Community
2 | =========
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | releases
8 | review-comments
9 | reviews
10 | mentoring
11 | speaker-mentoring
12 |
--------------------------------------------------------------------------------
/contributing/community/mentoring.rst:
--------------------------------------------------------------------------------
1 | Mentoring
2 | =========
3 |
4 | Reading the :doc:`contributing ` is already a great way
5 | to get started on becoming a Symfony contributor. However, sometimes
6 | it might still seem overwhelming - contributing can be complex! For this
7 | purpose we created a dedicated `Symfony Slack`_ channel called `#mentoring`_
8 | to connect new contributors to long-time contributors. This is a great way
9 | to get one-on-one advice on the entire process. These long-time contributors
10 | do really want to help new contributors - so feel free to ask anything!
11 |
12 | .. _`Symfony Slack`: https://symfony.com/slack-invite
13 | .. _`#mentoring`: https://symfony-devs.slack.com/messages/mentoring
14 |
--------------------------------------------------------------------------------
/contributing/diversity/index.rst:
--------------------------------------------------------------------------------
1 | Diversity Initiative
2 | ====================
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | governance
8 |
--------------------------------------------------------------------------------
/contributing/documentation/index.rst:
--------------------------------------------------------------------------------
1 | Contributing Documentation
2 | ==========================
3 |
4 | These short articles explain everything you need to contribute to the Symfony
5 | documentation:
6 |
7 | :doc:`The Contribution Process `
8 | Explains the steps to follow to contribute fixes and new contents. It's the
9 | same contribution process followed by most open source projects, so you may
10 | already know everything that is needed.
11 |
12 | :doc:`Documentation Formats `
13 | Explains the technical details of the reStructuredText format that is used to
14 | write the docs. Skip it if you are already familiar with this format.
15 |
16 | :doc:`Documentation Standards `
17 | Explains how to write docs and code examples to match the style and tone of
18 | the rest of the existing documentation.
19 |
20 | :doc:`License `
21 | Explains the details of the Creative Commons BY-SA 3.0 license used for the
22 | Symfony Documentation.
23 |
24 | .. toctree::
25 | :hidden:
26 |
27 | format
28 | license
29 | overview
30 | standards
31 | translations
32 |
--------------------------------------------------------------------------------
/contributing/documentation/translations.rst:
--------------------------------------------------------------------------------
1 | Translations
2 | ============
3 |
4 | The official Symfony documentation is published only in English. You can
5 | read about the reasons in `this blog post`_.
6 |
7 | We have taken steps to improve the experience when using
8 | `Google Translate`_ to prevent code blocks from being translated.
9 |
10 | To translate any page in our documentation please copy any URL from the
11 | documentation and paste it into the form on the Google Translate site.
12 |
13 | .. _`this blog post`: https://symfony.com/blog/discontinuing-the-symfony-community-translations
14 | .. _`Google Translate`: https://translate.google.com
15 |
--------------------------------------------------------------------------------
/contributing/index.rst:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | .. toctree::
5 | :hidden:
6 |
7 | code_of_conduct/index
8 | code/index
9 | documentation/index
10 | community/index
11 | diversity/index
12 |
13 | .. include:: /contributing/map.rst.inc
14 |
--------------------------------------------------------------------------------
/contributing/map.rst.inc:
--------------------------------------------------------------------------------
1 | * **Code of Conduct**
2 |
3 | * :doc:`/contributing/code_of_conduct/code_of_conduct`
4 | * :doc:`/contributing/code_of_conduct/reporting_guidelines`
5 | * :doc:`/contributing/code_of_conduct/care_team`
6 | * :doc:`/contributing/code_of_conduct/concrete_example_document`
7 |
8 | * **Code**
9 |
10 | * :doc:`Bugs `
11 | * :doc:`Pull Requests `
12 | * :doc:`Reviewing Issues and Pull Requests `
13 | * :doc:`Maintenance `
14 | * :doc:`The Core Team `
15 | * :doc:`Security `
16 | * :doc:`Tests `
17 | * :doc:`Backward Compatibility `
18 | * :doc:`Coding Standards`
19 | * :doc:`Code Conventions`
20 | * :doc:`Git`
21 | * :doc:`License `
22 |
23 | * **Documentation**
24 |
25 | * :doc:`Overview `
26 | * :doc:`Format `
27 | * :doc:`Documentation Standards `
28 | * :doc:`License `
29 |
30 | * **Community**
31 |
32 | * :doc:`Release Process `
33 | * :doc:`Respectful Review comments `
34 | * :doc:`Community Reviews `
35 |
36 | * **Diversity**
37 |
38 | * :doc:`Governance `
39 |
--------------------------------------------------------------------------------
/controller/forwarding.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Controller; Forwarding
3 |
4 | How to Forward Requests to another Controller
5 | =============================================
6 |
7 | Though not very common, you can also forward to another controller internally
8 | with the ``forward()`` method provided by the
9 | :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController`
10 | class.
11 |
12 | Instead of redirecting the user's browser, this makes an "internal" sub-request
13 | and calls the defined controller. The ``forward()`` method returns the
14 | :class:`Symfony\\Component\\HttpFoundation\\Response` object that is returned
15 | from *that* controller::
16 |
17 | public function index($name)
18 | {
19 | $response = $this->forward('App\Controller\OtherController::fancy', [
20 | 'name' => $name,
21 | 'color' => 'green',
22 | ]);
23 |
24 | // ... further modify the response or return it directly
25 |
26 | return $response;
27 | }
28 |
29 | The array passed to the method becomes the arguments for the resulting controller.
30 | The target controller method might look something like this::
31 |
32 | public function fancy($name, $color)
33 | {
34 | // ... create and return a Response object
35 | }
36 |
37 | Just like when creating a controller for a route, the order of the arguments
38 | of the ``fancy()`` method doesn't matter: the matching is done by name.
39 |
--------------------------------------------------------------------------------
/create_framework/index.rst:
--------------------------------------------------------------------------------
1 | Create your own PHP Framework
2 | =============================
3 |
4 | .. toctree::
5 |
6 | introduction
7 | http_foundation
8 | front_controller
9 | routing
10 | templating
11 | http_kernel_controller_resolver
12 | separation_of_concerns
13 | unit_testing
14 | event_dispatcher
15 | http_kernel_httpkernelinterface
16 | http_kernel_httpkernel_class
17 | dependency_injection
18 |
--------------------------------------------------------------------------------
/create_framework/map.rst.inc:
--------------------------------------------------------------------------------
1 | * :doc:`/create_framework/introduction`
2 | * :doc:`/create_framework/http_foundation`
3 | * :doc:`/create_framework/front_controller`
4 | * :doc:`/create_framework/routing`
5 | * :doc:`/create_framework/templating`
6 | * :doc:`/create_framework/http_kernel_controller_resolver`
7 | * :doc:`/create_framework/separation_of_concerns`
8 | * :doc:`/create_framework/unit_testing`
9 | * :doc:`/create_framework/event_dispatcher`
10 | * :doc:`/create_framework/http_kernel_httpkernelinterface`
11 | * :doc:`/create_framework/http_kernel_httpkernel_class`
12 | * :doc:`/create_framework/dependency_injection`
13 |
--------------------------------------------------------------------------------
/deployment/azure-website.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | .. index::
4 | single: Deployment; Deploying to Microsoft Azure Website Cloud
5 |
6 | Deploying to Microsoft Azure
7 | ============================
8 |
9 | If you want information about deploying to Azure, see their official documentation:
10 | `Create your PHP web application on Azure`_
11 |
12 | .. _`Create your PHP web application on Azure`: https://azure.microsoft.com/en-us/develop/php/
13 |
--------------------------------------------------------------------------------
/deployment/fortrabbit.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | .. index::
4 | single: Deployment; Deploying to fortrabbit.com
5 |
6 | Deploying to fortrabbit
7 | =======================
8 |
9 | For details on deploying to fortrabbit, see their official documentation:
10 | `Install Symfony`_
11 |
12 | .. _`Install Symfony`: https://help.fortrabbit.com/install-symfony-3-uni
13 |
--------------------------------------------------------------------------------
/deployment/heroku.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | .. index::
4 | single: Deployment; Deploying to Heroku Cloud
5 |
6 | Deploying to Heroku
7 | ===================
8 |
9 | To deploy to Heroku, see their official documentation:
10 | `Deploying Symfony 4 Apps on Heroku`_.
11 |
12 | .. _`Deploying Symfony 4 Apps on Heroku`: https://devcenter.heroku.com/articles/deploying-symfony4
13 |
--------------------------------------------------------------------------------
/deployment/platformsh.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | .. index::
4 | single: Deployment; Deploying to Platform.sh
5 |
6 | Deploying to Platform.sh
7 | ========================
8 |
9 | To deploy to Platform.sh, see their official documentation:
10 | `Symfony Platform.sh Documentation`_.
11 |
12 | .. _`Symfony Platform.sh Documentation`: https://docs.platform.sh/frameworks/symfony.html
13 |
--------------------------------------------------------------------------------
/doctrine/registration_form.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Doctrine; Simple Registration Form
3 | single: Form; Simple Registration Form
4 | single: Security; Simple Registration Form
5 |
6 | How to Implement a Registration Form
7 | ====================================
8 |
9 | This article has been removed because it only explained things that are
10 | already explained in other articles. Specifically, to implement a registration
11 | form you must:
12 |
13 | #. :ref:`Define a class to represent users `;
14 | #. :doc:`Create a form ` to ask for the registration information (you can
15 | generate this with the ``make:registration-form`` command provided by the `MakerBundle`_);
16 | #. Create :doc:`a controller ` to :ref:`process the form `;
17 | #. :ref:`Protect some parts of your application ` so
18 | only registered users can access to them.
19 |
20 | .. _`MakerBundle`: https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html
21 |
--------------------------------------------------------------------------------
/form/button_based_validation.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Forms; Validation groups based on clicked button
3 |
4 | How to Choose Validation Groups Based on the Clicked Button
5 | ===========================================================
6 |
7 | When your form contains multiple submit buttons, you can change the validation
8 | group depending on which button is used to submit the form. For example,
9 | consider a form in a wizard that lets you advance to the next step or go back
10 | to the previous step. Also assume that when returning to the previous step,
11 | the data of the form should be saved, but not validated.
12 |
13 | First, we need to add the two buttons to the form::
14 |
15 | $form = $this->createFormBuilder($task)
16 | // ...
17 | ->add('nextStep', SubmitType::class)
18 | ->add('previousStep', SubmitType::class)
19 | ->getForm();
20 |
21 | Then, we configure the button for returning to the previous step to run
22 | specific validation groups. In this example, we want it to suppress validation,
23 | so we set its ``validation_groups`` option to false::
24 |
25 | $form = $this->createFormBuilder($task)
26 | // ...
27 | ->add('previousStep', SubmitType::class, [
28 | 'validation_groups' => false,
29 | ])
30 | ->getForm();
31 |
32 | Now the form will skip your validation constraints. It will still validate
33 | basic integrity constraints, such as checking whether an uploaded file was too
34 | large or whether you tried to submit text in a number field.
35 |
36 | .. seealso::
37 |
38 | To see how to use a service to resolve ``validation_groups`` dynamically
39 | read the :doc:`/form/validation_group_service_resolver` article.
40 |
--------------------------------------------------------------------------------
/form/disabling_validation.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Forms; Disabling validation
3 |
4 | How to Disable the Validation of Submitted Data
5 | ===============================================
6 |
7 | Sometimes it is useful to suppress the validation of a form altogether. For
8 | these cases you can set the ``validation_groups`` option to ``false``::
9 |
10 | use Symfony\Component\OptionsResolver\OptionsResolver;
11 |
12 | public function configureOptions(OptionsResolver $resolver)
13 | {
14 | $resolver->setDefaults([
15 | 'validation_groups' => false,
16 | ]);
17 | }
18 |
19 | Note that when you do that, the form will still run basic integrity checks,
20 | for example whether an uploaded file was too large or whether non-existing
21 | fields were submitted.
22 |
23 | The submission of extra form fields can be controlled with the
24 | :ref:`allow_extra_fields config option ` and
25 | the maximum upload file size should be handled via your PHP and web server
26 | configuration.
27 |
--------------------------------------------------------------------------------
/form/form_dependencies.rst:
--------------------------------------------------------------------------------
1 | How to Access Services or Config from Inside a Form
2 | ===================================================
3 |
4 | The content of this article is no longer relevant because in current Symfony
5 | versions, form classes are services by default and you can inject services in
6 | them using the :doc:`service autowiring ` feature.
7 |
8 | Read the article about :doc:`creating custom form types `
9 | to see an example of how to inject the database service into a form type. In the
10 | same article you can also read about
11 | :ref:`configuration options for form types `, which is
12 | another way of passing services to forms.
13 |
--------------------------------------------------------------------------------
/form/multiple_buttons.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Forms; Multiple Submit Buttons
3 |
4 | How to Submit a Form with Multiple Buttons
5 | ==========================================
6 |
7 | When your form contains more than one submit button, you will want to check
8 | which of the buttons was clicked to adapt the program flow in your controller.
9 | To do this, add a second button with the caption "Save and add" to your form::
10 |
11 | $form = $this->createFormBuilder($task)
12 | ->add('task', TextType::class)
13 | ->add('dueDate', DateType::class)
14 | ->add('save', SubmitType::class, ['label' => 'Create Task'])
15 | ->add('saveAndAdd', SubmitType::class, ['label' => 'Save and Add'])
16 | ->getForm();
17 |
18 | In your controller, use the button's
19 | :method:`Symfony\\Component\\Form\\ClickableInterface::isClicked` method for
20 | querying if the "Save and add" button was clicked::
21 |
22 | if ($form->isSubmitted() && $form->isValid()) {
23 | // ... perform some action, such as saving the task to the database
24 |
25 | $nextAction = $form->get('saveAndAdd')->isClicked()
26 | ? 'task_new'
27 | : 'task_success';
28 |
29 | return $this->redirectToRoute($nextAction);
30 | }
31 |
32 | Or you can get the button's name by using the
33 | :method:`Symfony\\Component\\Form\\Form::getClickedButton` method of the form::
34 |
35 | if ($form->getClickedButton() && 'saveAndAdd' === $form->getClickedButton()->getName()) {
36 | // ...
37 | }
38 |
39 | // when using nested forms, two or more buttons can have the same name;
40 | // in those cases, compare the button objects instead of the button names
41 | if ($form->getClickedButton() === $form->get('saveAndAdd')){
42 | // ...
43 | }
44 |
--------------------------------------------------------------------------------
/form/validation_groups.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Forms; Validation groups
3 |
4 | How to Define the Validation Groups to Use
5 | ==========================================
6 |
7 | Validation Groups
8 | -----------------
9 |
10 | If your object takes advantage of :doc:`validation groups `,
11 | you'll need to specify which validation group(s) your form should use. Pass
12 | this as an option when :ref:`creating forms in controllers `::
13 |
14 | $form = $this->createFormBuilder($user, [
15 | 'validation_groups' => ['registration'],
16 | ])->add(...);
17 |
18 | When :ref:`creating forms in classes `, add the
19 | following to the ``configureOptions()`` method::
20 |
21 | use Symfony\Component\OptionsResolver\OptionsResolver;
22 |
23 | public function configureOptions(OptionsResolver $resolver)
24 | {
25 | $resolver->setDefaults([
26 | // ...
27 | 'validation_groups' => ['registration'],
28 | ]);
29 | }
30 |
31 | In both of these cases, *only* the ``registration`` validation group will
32 | be used to validate the underlying object. To apply the ``registration``
33 | group *and* all constraints that are not in a group, use::
34 |
35 | 'validation_groups' => ['Default', 'registration']
36 |
37 | .. note::
38 |
39 | You can choose any name for your validation groups, but Symfony recommends
40 | using "lower snake case" names (e.g. ``foo_bar``) in contrast with the
41 | automatic validation groups created by Symfony, which use "upper camel case"
42 | (e.g. ``Default``, ``SomeClassName``).
43 |
--------------------------------------------------------------------------------
/frontend/assetic/index.rst:
--------------------------------------------------------------------------------
1 | Assetic
2 | =======
3 |
4 | .. caution::
5 |
6 | Using Assetic to manage web assets in Symfony applications is no longer
7 | recommended. Instead, use :doc:`Webpack Encore `, which bridges
8 | Symfony applications with modern JavaScript-based tools to manage web assets.
9 |
--------------------------------------------------------------------------------
/frontend/encore/cdn.rst:
--------------------------------------------------------------------------------
1 | Using a CDN
2 | ===========
3 |
4 | Are you deploying to a CDN? That's awesome :) Once you've made sure that your
5 | built files are uploaded to the CDN, configure it in Encore:
6 |
7 | .. code-block:: diff
8 |
9 | // webpack.config.js
10 | // ...
11 |
12 | Encore
13 | .setOutputPath('public/build/')
14 | // in dev mode, don't use the CDN
15 | .setPublicPath('/build');
16 | // ...
17 | ;
18 |
19 | + if (Encore.isProduction()) {
20 | + Encore.setPublicPath('https://my-cool-app.com.global.prod.fastly.net');
21 | +
22 | + // guarantee that the keys in manifest.json are *still*
23 | + // prefixed with build/
24 | + // (e.g. "build/dashboard.js": "https://my-cool-app.com.global.prod.fastly.net/dashboard.js")
25 | + Encore.setManifestKeyPrefix('build/');
26 | + }
27 |
28 | That's it! Internally, Webpack will now know to load assets from your CDN -
29 | e.g. ``https://my-cool-app.com.global.prod.fastly.net/dashboard.js``.
30 |
31 | .. note::
32 |
33 | It's still your responsibility to put your assets on the CDN - e.g. by
34 | uploading them or by using "origin pull", where your CDN pulls assets
35 | directly from your web server.
36 |
37 | You *do* need to make sure that the ``script`` and ``link`` tags you include on your
38 | pages also use the CDN. Fortunately, the
39 | :ref:`entrypoints.json ` paths are updated
40 | to include the full URL to the CDN.
41 |
42 | If you are using ``Encore.enableIntegrityHashes()`` and your CDN and your domain
43 | are not the `same-origin`_, you may need to set the ``crossorigin`` option in
44 | your webpack_encore.yaml configuration to ``anonymous`` or ``use-credentials``
45 | to overcome CORS errors.
46 |
47 | .. _`same-origin`: https://en.wikipedia.org/wiki/Same-origin_policy
48 |
--------------------------------------------------------------------------------
/frontend/encore/css-preprocessors.rst:
--------------------------------------------------------------------------------
1 | CSS Preprocessors: Sass, LESS, Stylus, etc.
2 | ===========================================
3 |
4 | To use the Sass, LESS or Stylus pre-processors, enable the one you want in ``webpack.config.js``:
5 |
6 | .. code-block:: javascript
7 |
8 | // webpack.config.js
9 | // ...
10 |
11 | Encore
12 | // ...
13 |
14 | // enable just the one you want
15 |
16 | // processes files ending in .scss or .sass
17 | .enableSassLoader()
18 |
19 | // processes files ending in .less
20 | .enableLessLoader()
21 |
22 | // processes files ending in .styl
23 | .enableStylusLoader()
24 | ;
25 |
26 | Then restart Encore. When you do, it will give you a command you can run to
27 | install any missing dependencies. After running that command and restarting
28 | Encore, you're done!
29 |
30 | You can also pass configuration options to each of the loaders. See the
31 | `Encore's index.js file`_ for detailed documentation.
32 |
33 | .. _`Encore's index.js file`: https://github.com/symfony/webpack-encore/blob/master/index.js
34 |
--------------------------------------------------------------------------------
/frontend/encore/page-specific-assets.rst:
--------------------------------------------------------------------------------
1 | Creating Page-Specific CSS/JS
2 | =============================
3 |
4 | If you're creating a single page app (SPA), then you probably only need to define
5 | *one* entry in ``webpack.config.js``. But if you have multiple pages, you might
6 | want page-specific CSS and JavaScript.
7 |
8 | To learn how to set this up, see the :ref:`multiple-javascript-entries` example.
9 |
10 | Multiple Entries Per Page?
11 | --------------------------
12 |
13 | Typically, you should include only *one* JavaScript entry per page. Think of the
14 | checkout page as its own "app", where ``checkout.js`` includes all the functionality
15 | you need.
16 |
17 | However, it's pretty common to need to include some global JavaScript and CSS on
18 | every page. For that reason, it usually makes sense to have one entry (e.g. ``app``)
19 | that contains this global code (both JavaScript & CSS) and is included on every
20 | page (i.e. it's included in the *layout* of your app). This means that you will
21 | always have one, global entry on every page (e.g. ``app``) and you *may* have one
22 | page-specific JavaScript and CSS file from a page-specific entry (e.g. ``checkout``).
23 |
24 | .. tip::
25 |
26 | Be sure to use :doc:`split chunks `
27 | to avoid duplicating and shared code between your entry files.
28 |
--------------------------------------------------------------------------------
/frontend/encore/reactjs.rst:
--------------------------------------------------------------------------------
1 | Enabling React.js
2 | =================
3 |
4 | .. admonition:: Screencast
5 | :class: screencast
6 |
7 | Do you prefer video tutorials? Check out the `React.js screencast series`_.
8 |
9 | Using React? First add some dependencies with Yarn:
10 |
11 | .. code-block:: terminal
12 |
13 | $ yarn add @babel/preset-react --dev
14 | $ yarn add react react-dom prop-types
15 |
16 | Enable react in your ``webpack.config.js``:
17 |
18 | .. code-block:: diff
19 |
20 | // webpack.config.js
21 | // ...
22 |
23 | Encore
24 | // ...
25 | + .enableReactPreset()
26 | ;
27 |
28 |
29 | Then restart Encore. When you do, it will give you a command you can run to
30 | install any missing dependencies. After running that command and restarting
31 | Encore, you're done!
32 |
33 | Your ``.js`` and ``.jsx`` files will now be transformed through ``babel-preset-react``.
34 |
35 | .. _`React.js screencast series`: https://symfonycasts.com/screencast/reactjs
36 |
--------------------------------------------------------------------------------
/frontend/encore/server-data.rst:
--------------------------------------------------------------------------------
1 | Passing Information from Twig to JavaScript
2 | ===========================================
3 |
4 | In Symfony applications, you may find that you need to pass some dynamic data
5 | (e.g. user information) from Twig to your JavaScript code. One great way to pass
6 | dynamic configuration is by storing information in ``data`` attributes and reading
7 | them later in JavaScript. For example:
8 |
9 | .. code-block:: html+twig
10 |
11 |
12 |
13 |
14 |
15 | Fetch this in JavaScript:
16 |
17 | .. code-block:: javascript
18 |
19 | document.addEventListener('DOMContentLoaded', function() {
20 | var userRating = document.querySelector('.js-user-rating');
21 | var isAuthenticated = userRating.dataset.isAuthenticated;
22 |
23 | // or with jQuery
24 | //var isAuthenticated = $('.js-user-rating').data('isAuthenticated');
25 | });
26 |
27 | .. note::
28 |
29 | When `accessing data attributes from JavaScript`_, the attribute names are
30 | converted from dash-style to camelCase. For example, ``data-is-authenticated``
31 | becomes ``isAuthenticated`` and ``data-number-of-reviews`` becomes
32 | ``numberOfReviews``.
33 |
34 | There is no size limit for the value of the ``data-`` attributes, so you can
35 | store any content. In Twig, use the ``html_attr`` escaping strategy to avoid messing
36 | with HTML attributes. For example, if your ``User`` object has some ``getProfileData()``
37 | method that returns an array, you could do the following:
38 |
39 | .. code-block:: html+twig
40 |
41 |
42 |
43 |
44 |
45 | .. _`accessing data attributes from JavaScript`: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
46 |
--------------------------------------------------------------------------------
/frontend/encore/shared-entry.rst:
--------------------------------------------------------------------------------
1 | Creating a Shared Commons Entry
2 | ===============================
3 |
4 | .. caution::
5 |
6 | While this method still works, see :doc:`/frontend/encore/split-chunks` for
7 | the preferred solution to sharing assets between multiple entry files.
8 |
9 | Suppose you have multiple entry files and *each* requires ``jquery``. In this
10 | case, *each* output file will contain jQuery, slowing down your user's experience.
11 | To solve this, you can *extract* the common libraries to a "shared" entry file
12 | that's included on every page.
13 |
14 | Suppose you already have an entry called ``app`` that's included on every page.
15 | Update your code to use ``createSharedEntry()``:
16 |
17 | .. code-block:: diff
18 |
19 | Encore
20 | // ...
21 | - .addEntry('app', './assets/js/app.js')
22 | + .createSharedEntry('app', './assets/js/app.js')
23 | .addEntry('homepage', './assets/js/homepage.js')
24 | .addEntry('blog', './assets/js/blog.js')
25 | .addEntry('store', './assets/js/store.js')
26 |
27 | Before making this change, if both ``app.js`` and ``store.js`` require ``jquery``,
28 | then ``jquery`` would be packaged into *both* files, which is wasteful. By making
29 | ``app.js`` your "shared" entry, *any* code required by ``app.js`` (like jQuery) will
30 | *no longer* be packaged into any other files. The same is true for any CSS.
31 |
32 | Because ``app.js`` contains all the common code that other entry files depend on,
33 | its script (and link) tag must be on every page.
34 |
35 | .. tip::
36 |
37 | The ``app.js`` file works best when its contents are changed *rarely*
38 | and you're using :ref:`long-term caching `. Why?
39 | If ``app.js`` contains application code that *frequently* changes, then
40 | (when using versioning), its filename hash will frequently change. This means
41 | your users won't enjoy the benefits of long-term caching for this file (which
42 | is generally quite large).
43 |
--------------------------------------------------------------------------------
/frontend/encore/sourcemaps.rst:
--------------------------------------------------------------------------------
1 | Enabling Source Maps
2 | ====================
3 |
4 | `Source maps`_ allow browsers to access the original code related to some
5 | asset (e.g. the Sass code that was compiled to CSS or the TypeScript code that
6 | was compiled to JavaScript). Source maps are useful for debugging purposes but
7 | unnecessary when executing the application in production.
8 |
9 | Encore's default ``webpack.config.js`` file enables source maps in the ``dev``
10 | build:
11 |
12 | .. code-block:: javascript
13 |
14 | // webpack.config.js
15 | // ...
16 |
17 | Encore
18 | // ...
19 |
20 | .enableSourceMaps(!Encore.isProduction())
21 | ;
22 |
23 | .. _`Source maps`: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map
24 |
--------------------------------------------------------------------------------
/frontend/encore/url-loader.rst:
--------------------------------------------------------------------------------
1 | Inlining files in CSS with Webpack URL Loader
2 | =============================================
3 |
4 | A simple technique to improve the performance of web applications is to reduce
5 | the number of HTTP requests inlining small files as base64 encoded URLs in the
6 | generated CSS files.
7 |
8 | Webpack Encore provides this feature via Webpack's `URL Loader`_ plugin, but
9 | it's disabled by default. First, add the URL loader to your project:
10 |
11 | .. code-block:: terminal
12 |
13 | $ yarn add url-loader --dev
14 |
15 | Then enable it in your ``webpack.config.js``:
16 |
17 | .. code-block:: javascript
18 |
19 | // webpack.config.js
20 | // ...
21 |
22 | Encore
23 | // ...
24 | .configureUrlLoader({
25 | fonts: { limit: 4096 },
26 | images: { limit: 4096 }
27 | })
28 | ;
29 |
30 | The ``limit`` option defines the maximum size in bytes of the inlined files. In
31 | the previous example, font and image files having a size below or equal to 4 KB
32 | will be inlined and the rest of files will be processed as usual.
33 |
34 | You can also use all the other options supported by the `URL Loader`_. If you
35 | want to disable this loader for either images or fonts, remove the corresponding
36 | key from the object that is passed to the ``configureUrlLoader()`` method:
37 |
38 | .. code-block:: javascript
39 |
40 | // webpack.config.js
41 | // ...
42 |
43 | Encore
44 | // ...
45 | .configureUrlLoader({
46 | // 'fonts' is not defined, so only images will be inlined
47 | images: { limit: 4096 }
48 | })
49 | ;
50 |
51 | .. _`URL Loader`: https://github.com/webpack-contrib/url-loader
52 |
--------------------------------------------------------------------------------
/getting_started/index.rst:
--------------------------------------------------------------------------------
1 | Getting Started
2 | ---------------
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | /setup
8 | /page_creation
9 | /routing
10 | /controller
11 | /templates
12 | /configuration
13 |
--------------------------------------------------------------------------------
/http_cache/_expiration-and-validation.rst.inc:
--------------------------------------------------------------------------------
1 | .. sidebar:: Expiration and Validation
2 |
3 | You can use both validation and expiration within the same ``Response``.
4 | As expiration wins over validation, you can benefit from the best of
5 | both worlds. In other words, by using both expiration and validation, you
6 | can instruct the cache to serve the cached content, while checking back
7 | at some interval (the expiration) to verify that the content is still valid.
8 |
9 | .. tip::
10 |
11 | You can also define HTTP caching headers for expiration and validation by using
12 | annotations. See the `FrameworkExtraBundle documentation`_.
13 |
14 | .. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html
15 |
--------------------------------------------------------------------------------
/http_cache/cache_vary.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Cache; Vary
3 | single: HTTP headers; Vary
4 |
5 | Varying the Response for HTTP Cache
6 | ===================================
7 |
8 | So far, it's been assumed that each URI has exactly one representation of the
9 | target resource. By default, HTTP caching is done by using the URI of the
10 | resource as the cache key. If two people request the same URI of a cacheable
11 | resource, the second person will receive the cached version.
12 |
13 | Sometimes this isn't enough and different versions of the same URI need to
14 | be cached based on one or more request header values. For instance, if you
15 | compress pages when the client supports it, any given URI has two representations:
16 | one when the client supports compression, and one when it does not. This
17 | determination is done by the value of the ``Accept-Encoding`` request header.
18 |
19 | In this case, you need the cache to store both a compressed and uncompressed
20 | version of the response for the particular URI and return them based on the
21 | request's ``Accept-Encoding`` value. This is done by using the ``Vary`` response
22 | header, which is a comma-separated list of different headers whose values
23 | trigger a different representation of the requested resource:
24 |
25 | .. code-block:: text
26 |
27 | Vary: Accept-Encoding, User-Agent
28 |
29 | .. tip::
30 |
31 | This particular ``Vary`` header would cache different versions of each
32 | resource based on the URI and the value of the ``Accept-Encoding`` and
33 | ``User-Agent`` request header.
34 |
35 | The ``Response`` object offers a clean interface for managing the ``Vary``
36 | header::
37 |
38 | // sets one vary header
39 | $response->setVary('Accept-Encoding');
40 |
41 | // sets multiple vary headers
42 | $response->setVary(['Accept-Encoding', 'User-Agent']);
43 |
44 | The ``setVary()`` method takes a header name or an array of header names for
45 | which the response varies.
46 |
--------------------------------------------------------------------------------
/index.rst:
--------------------------------------------------------------------------------
1 | .. _symfony2-documentation:
2 |
3 | Symfony Documentation
4 | =====================
5 |
6 | Quick Tour
7 | ----------
8 |
9 | Get started fast with the Symfony :doc:`Quick Tour `:
10 |
11 | .. toctree::
12 | :hidden:
13 |
14 | quick_tour/index
15 |
16 | * :doc:`quick_tour/the_big_picture`
17 | * :doc:`quick_tour/flex_recipes`
18 | * :doc:`quick_tour/the_architecture`
19 |
20 | Getting Started
21 | ---------------
22 |
23 | .. toctree::
24 | :maxdepth: 2
25 |
26 | getting_started/index
27 |
28 | Topics
29 | ------
30 |
31 | .. toctree::
32 | :maxdepth: 1
33 |
34 | best_practices
35 | bundles
36 | cache
37 | console
38 | doctrine
39 | deployment
40 | email
41 | event_dispatcher
42 | forms
43 | frontend
44 | http_cache
45 | logging
46 | mailer
47 | mercure
48 | messenger
49 | migration
50 | notifier
51 | performance
52 | profiler
53 | routing
54 | security
55 | session
56 | setup
57 | serializer
58 | service_container
59 | testing
60 | translation
61 | validation
62 | web_link
63 | workflow
64 |
65 | Components
66 | ----------
67 |
68 | .. toctree::
69 | :hidden:
70 |
71 | components/index
72 |
73 | Read the :doc:`Components ` documentation.
74 |
75 | Reference Documents
76 | -------------------
77 |
78 | Get answers quickly with reference documents:
79 |
80 | .. toctree::
81 | :hidden:
82 |
83 | reference/index
84 |
85 | .. include:: /reference/map.rst.inc
86 |
87 | Contributing
88 | ------------
89 |
90 | Contribute to Symfony:
91 |
92 | .. toctree::
93 | :hidden:
94 |
95 | contributing/index
96 |
97 | .. include:: /contributing/map.rst.inc
98 |
99 | Create your Own Framework
100 | -------------------------
101 |
102 | Want to create your own framework based on Symfony?
103 |
104 | .. toctree::
105 | :hidden:
106 |
107 | create_framework/index
108 |
109 | .. include:: /create_framework/map.rst.inc
110 |
--------------------------------------------------------------------------------
/notifier/texters.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Notifier; Texters
3 |
4 | How to send SMS Messages
5 | ========================
6 |
7 | .. versionadded:: 5.0
8 |
9 | The Notifier component was introduced in Symfony 5.0 as an
10 | :doc:`experimental feature `.
11 |
12 | The :class:`Symfony\\Component\\Notifier\\TexterInterface` class allows
13 | you to send SMS messages::
14 |
15 | // src/Controller/SecurityController.php
16 | namespace App\Controller;
17 |
18 | use Symfony\Component\Notifier\Message\SmsMessage;
19 | use Symfony\Component\Notifier\TexterInterface;
20 | use Symfony\Component\Routing\Annotation\Route;
21 |
22 | class SecurityController
23 | {
24 | /**
25 | * @Route("/login/success")
26 | */
27 | public function loginSuccess(TexterInterface $texter)
28 | {
29 | $sms = new SmsMessage(
30 | // the phone number to send the SMS message to
31 | '+1411111111',
32 | // the message
33 | 'A new login was detected!'
34 | );
35 |
36 | $texter->send($sms);
37 |
38 | // ...
39 | }
40 | }
41 |
42 | .. seealso::
43 |
44 | Read :ref:`the main Notifier guide ` to see how
45 | to configure the different transports.
46 |
--------------------------------------------------------------------------------
/quick_tour/index.rst:
--------------------------------------------------------------------------------
1 | The Quick Tour
2 | ==============
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | the_big_picture
8 | flex_recipes
9 | the_architecture
10 |
--------------------------------------------------------------------------------
/reference/configuration/monolog.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | pair: Monolog; Configuration reference
3 |
4 | Logging Configuration Reference (MonologBundle)
5 | ===============================================
6 |
7 | The MonologBundle integrates the Monolog :doc:`logging ` library in
8 | Symfony applications. All these options are configured under the ``monolog`` key
9 | in your application configuration.
10 |
11 | .. code-block:: terminal
12 |
13 | # displays the default config values defined by Symfony
14 | $ php bin/console config:dump-reference monolog
15 |
16 | # displays the actual config values used by your application
17 | $ php bin/console debug:config monolog
18 |
19 | .. note::
20 |
21 | When using XML, you must use the ``http://symfony.com/schema/dic/monolog``
22 | namespace and the related XSD schema is available at:
23 | ``https://symfony.com/schema/dic/monolog/monolog-1.0.xsd``
24 |
25 | .. tip::
26 |
27 | For a full list of handler types and related configuration options, see
28 | `Monolog Configuration`_.
29 |
30 | .. note::
31 |
32 | When the profiler is enabled, a handler is added to store the logs'
33 | messages in the profiler. The profiler uses the name "debug" so it
34 | is reserved and cannot be used in the configuration.
35 |
36 | .. _`Monolog Configuration`: https://github.com/symfony/monolog-bundle/blob/master/DependencyInjection/Configuration.php
37 |
--------------------------------------------------------------------------------
/reference/constraints/_comparison-propertypath-option.rst.inc:
--------------------------------------------------------------------------------
1 | ``propertyPath``
2 | ~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``string``
5 |
6 | It defines the object property whose value is used to make the comparison.
7 |
8 | For example, if you want to compare the ``$endDate`` property of some object
9 | with regard to the ``$startDate`` property of the same object, use
10 | ``propertyPath="startDate"`` in the comparison constraint of ``$endDate``.
11 |
12 | .. tip::
13 |
14 | When using this option, its value is available in error messages as the
15 | ``{{ compared_value_path }}`` placeholder. Although it's not intended to
16 | include it in the error messages displayed to end users, it's useful when
17 | using APIs for doing any mapping logic on client-side.
18 |
--------------------------------------------------------------------------------
/reference/constraints/_comparison-value-option.rst.inc:
--------------------------------------------------------------------------------
1 | ``value``
2 | ~~~~~~~~~
3 |
4 | **type**: ``mixed`` [:ref:`default option `]
5 |
6 | This option is required. It defines the value to compare to. It can be a
7 | string, number or object.
8 |
--------------------------------------------------------------------------------
/reference/constraints/_empty-values-are-valid.rst.inc:
--------------------------------------------------------------------------------
1 | .. note::
2 |
3 | As with most of the other constraints, ``null`` and empty strings are
4 | considered valid values. This is to allow them to be optional values.
5 | If the value is mandatory, a common solution is to combine this constraint
6 | with :doc:`NotBlank `.
7 |
--------------------------------------------------------------------------------
/reference/constraints/_groups-option.rst.inc:
--------------------------------------------------------------------------------
1 | ``groups``
2 | ~~~~~~~~~~
3 |
4 | **type**: ``array`` | ``string``
5 |
6 | It defines the validation group or groups this constraint belongs to. Read more
7 | about :doc:`validation groups `.
8 |
--------------------------------------------------------------------------------
/reference/constraints/_normalizer-option.rst.inc:
--------------------------------------------------------------------------------
1 | normalizer
2 | ~~~~~~~~~~
3 |
4 | **type**: a `PHP callable`_ **default**: ``null``
5 |
6 | This option allows to define the PHP callable applied to the given value before
7 | checking if it is valid.
8 |
9 | For example, you may want to pass the ``'trim'`` string to apply the
10 | :phpfunction:`trim` PHP function in order to ignore leading and trailing
11 | whitespace during validation.
12 |
13 | .. _`PHP callable`: https://www.php.net/callable
14 |
--------------------------------------------------------------------------------
/reference/constraints/_payload-option.rst.inc:
--------------------------------------------------------------------------------
1 | ``payload``
2 | ~~~~~~~~~~~
3 |
4 | **type**: ``mixed`` **default**: ``null``
5 |
6 | This option can be used to attach arbitrary domain-specific data to a constraint.
7 | The configured payload is not used by the Validator component, but its processing
8 | is completely up to you.
9 |
10 | For example, you may want to use
11 | :doc:`several error levels ` to present failed
12 | constraints differently in the front-end depending on the severity of the
13 | error.
14 |
--------------------------------------------------------------------------------
/reference/forms/types.rst:
--------------------------------------------------------------------------------
1 | .. index::
2 | single: Forms; Types Reference
3 |
4 | Form Types Reference
5 | ====================
6 |
7 | .. toctree::
8 | :maxdepth: 1
9 | :hidden:
10 |
11 | types/text
12 | types/textarea
13 | types/email
14 | types/integer
15 | types/money
16 | types/number
17 | types/password
18 | types/percent
19 | types/search
20 | types/url
21 | types/range
22 | types/tel
23 | types/color
24 |
25 | types/choice
26 | types/entity
27 | types/country
28 | types/language
29 | types/locale
30 | types/timezone
31 | types/currency
32 |
33 | types/date
34 | types/dateinterval
35 | types/datetime
36 | types/time
37 | types/birthday
38 | types/week
39 |
40 | types/checkbox
41 | types/file
42 | types/radio
43 |
44 | types/collection
45 | types/repeated
46 |
47 | types/hidden
48 |
49 | types/button
50 | types/reset
51 | types/submit
52 |
53 | types/form
54 |
55 | A form is composed of *fields*, each of which are built with the help of
56 | a field *type* (e.g. ``TextType``, ``ChoiceType``, etc). Symfony comes
57 | standard with a large list of field types that can be used in your application.
58 |
59 | Supported Field Types
60 | ---------------------
61 |
62 | The following field types are natively available in Symfony:
63 |
64 | .. include:: /reference/forms/types/map.rst.inc
65 |
--------------------------------------------------------------------------------
/reference/forms/types/options/_date_limitation.rst.inc:
--------------------------------------------------------------------------------
1 | .. caution::
2 |
3 | If ``timestamp`` is used, ``DateType`` is limited to dates between
4 | Fri, 13 Dec 1901 20:45:54 GMT and Tue, 19 Jan 2038 03:14:07 GMT on 32bit
5 | systems. This is due to a `limitation in PHP itself`_.
6 |
7 | .. _limitation in PHP itself: https://www.php.net/manual/en/function.date.php#refsect1-function.date-changelog
8 |
--------------------------------------------------------------------------------
/reference/forms/types/options/_debug_form.rst.inc:
--------------------------------------------------------------------------------
1 | .. tip::
2 |
3 | The full list of options defined and inherited by this form type is
4 | available running this command in your app:
5 |
6 | .. code-block:: terminal
7 |
8 | # replace 'FooType' by the class name of your form type
9 | $ php bin/console debug:form FooType
10 |
--------------------------------------------------------------------------------
/reference/forms/types/options/_error_bubbling_body.rst.inc:
--------------------------------------------------------------------------------
1 | If ``true``, any errors for this field will be passed to the parent field
2 | or form. For example, if set to ``true`` on a normal field, any errors for
3 | that field will be attached to the main form, not to the specific field.
4 |
--------------------------------------------------------------------------------
/reference/forms/types/options/_error_bubbling_hint.rst.inc:
--------------------------------------------------------------------------------
1 | .. tip::
2 |
3 | By default, the ``error_bubbling`` option is enabled for the
4 | :doc:`collection Field Type `,
5 | which passes the errors to the parent form. If you want to attach
6 | the errors to the locations where they actually occur you have to
7 | set ``error_bubbling`` to ``false``.
8 |
--------------------------------------------------------------------------------
/reference/forms/types/options/action.rst.inc:
--------------------------------------------------------------------------------
1 | ``action``
2 | ~~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: empty string
5 |
6 | This option specifies where to send the form's data on submission (usually
7 | a URI). Its value is rendered as the ``action`` attribute of the ``form``
8 | element. An empty value is considered a same-document reference, i.e. the
9 | form will be submitted to the same URI that rendered the form.
10 |
--------------------------------------------------------------------------------
/reference/forms/types/options/attr.rst.inc:
--------------------------------------------------------------------------------
1 | ``attr``
2 | ~~~~~~~~
3 |
4 | **type**: ``array`` **default**: ``[]``
5 |
6 | If you want to add extra attributes to an HTML field representation
7 | you can use the ``attr`` option. It's an associative array with HTML attributes
8 | as keys. This can be useful when you need to set a custom class for some widget::
9 |
10 | $builder->add('body', TextareaType::class, [
11 | 'attr' => ['class' => 'tinymce'],
12 | ]);
13 |
14 | .. seealso::
15 |
16 | Use the ``row_attr`` option if you want to add these attributes to the
17 | the :ref:`form type row ` element.
18 |
--------------------------------------------------------------------------------
/reference/forms/types/options/attr_translation_parameters.rst.inc:
--------------------------------------------------------------------------------
1 | attr_translation_parameters
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``array`` **default**: ``[]``
5 |
6 | The content of the ``title`` and ``placeholder`` values defined in the `attr`_
7 | option is translated before displaying it, so it can contain
8 | :ref:`translation placeholders `. This
9 | option defines the values used to replace those placeholders.
10 |
11 | Given this translation message:
12 |
13 | .. code-block:: yaml
14 |
15 | # translations/messages.en.yaml
16 | form.order.id.placeholder: 'Enter unique identifier of the order to %company%'
17 | form.order.id.title: 'This will be the reference in communications with %company%'
18 |
19 | You can specify the placeholder values as follows::
20 |
21 | $builder->add('id', null, [
22 | 'attr' => [
23 | 'placeholder' => 'form.order.id.placeholder',
24 | 'title' => 'form.order.id.title',
25 | ],
26 | 'attr_translation_parameters' => [
27 | '%company%' => 'ACME Inc.',
28 | ],
29 | ]);
30 |
31 | The ``attr_translation_parameters`` option of children fields is merged with the
32 | same option of their parents, so children can reuse and/or override any of the
33 | parent placeholders.
34 |
--------------------------------------------------------------------------------
/reference/forms/types/options/auto_initialize.rst.inc:
--------------------------------------------------------------------------------
1 | ``auto_initialize``
2 | ~~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``true``
5 |
6 | An internal option: sets whether the form should be initialized automatically.
7 | For all fields, this option should only be ``true`` for root forms. You
8 | won't need to change this option and probably won't need to worry about
9 | it.
10 |
--------------------------------------------------------------------------------
/reference/forms/types/options/block_name.rst.inc:
--------------------------------------------------------------------------------
1 | ``block_name``
2 | ~~~~~~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: the form's name (see :ref:`Knowing which
5 | block to customize `)
6 |
7 | Allows you to add a custom block name to the ones used by default to render the
8 | form type. Useful for example if you have multiple instances of the same form
9 | and you need to personalize the rendering of the forms individually.
10 |
11 | If you set for example this option to ``my_custom_name`` and the field is of
12 | type ``text``, Symfony will use the following names (and in this order) to find
13 | the block used to render the widget of the field: ``_my_custom_name_widget``,
14 | ``text_widget`` and ``form_widget``.
15 |
--------------------------------------------------------------------------------
/reference/forms/types/options/block_prefix.rst.inc:
--------------------------------------------------------------------------------
1 | block_prefix
2 | ~~~~~~~~~~~~
3 |
4 | **type**: ``string`` or ``null`` **default**: ``null`` (see :ref:`Knowing which
5 | block to customize `)
6 |
7 | Allows you to add a custom block prefix and override the block name
8 | used to render the form type. Useful for example if you have multiple
9 | instances of the same form and you need to personalize the rendering
10 | of all of them without the need to create a new form type.
11 |
--------------------------------------------------------------------------------
/reference/forms/types/options/button_disabled.rst.inc:
--------------------------------------------------------------------------------
1 | ``disabled``
2 | ~~~~~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``false``
5 |
6 | If you don't want a user to be able to click a button, you can set the disabled
7 | option to true. It will not be possible to submit the form with this button,
8 | not even when bypassing the browser and sending a request manually, for
9 | example with cURL.
10 |
--------------------------------------------------------------------------------
/reference/forms/types/options/button_label.rst.inc:
--------------------------------------------------------------------------------
1 | ``label``
2 | ~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: The label is "guessed" from the field name
5 |
6 | Sets the label that will be displayed on the button. The label can also
7 | be directly set inside the template:
8 |
9 | .. configuration-block::
10 |
11 | .. code-block:: twig
12 |
13 | {{ form_widget(form.save, { 'label': 'Click me' }) }}
14 |
15 | .. code-block:: html+php
16 |
17 | = $view['form']->widget($form['save'], ['label' => 'Click me']) ?>
18 |
--------------------------------------------------------------------------------
/reference/forms/types/options/button_translation_domain.rst.inc:
--------------------------------------------------------------------------------
1 | ``translation_domain``
2 | ~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: ``messages``
5 |
6 | This is the translation domain that will be used for any labels or options
7 | that are rendered for this button.
8 |
--------------------------------------------------------------------------------
/reference/forms/types/options/by_reference.rst.inc:
--------------------------------------------------------------------------------
1 | ``by_reference``
2 | ~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``true``
5 |
6 | In most cases, if you have an ``author`` field, then you expect ``setAuthor()``
7 | to be called on the underlying object. In some cases, however, ``setAuthor()``
8 | may *not* be called. Setting ``by_reference`` to ``false`` ensures that the setter is
9 | called in all cases.
10 |
11 | To explain this further, here's a simple example::
12 |
13 | use Symfony\Component\Form\Extension\Core\Type\EmailType;
14 | use Symfony\Component\Form\Extension\Core\Type\FormType;
15 | use Symfony\Component\Form\Extension\Core\Type\TextType;
16 | // ...
17 |
18 | $builder = $this->createFormBuilder($article);
19 | $builder
20 | ->add('title', TextType::class)
21 | ->add(
22 | $builder->create('author', FormType::class, ['by_reference' => ?])
23 | ->add('name', TextType::class)
24 | ->add('email', EmailType::class)
25 | )
26 |
27 | If ``by_reference`` is true, the following takes place behind the scenes
28 | when you call ``submit()`` (or ``handleRequest()``) on the form::
29 |
30 | $article->setTitle('...');
31 | $article->getAuthor()->setName('...');
32 | $article->getAuthor()->setEmail('...');
33 |
34 | Notice that ``setAuthor()`` is not called. The author is modified by reference.
35 |
36 | If you set ``by_reference`` to false, submitting looks like this::
37 |
38 | $article->setTitle('...');
39 | $author = clone $article->getAuthor();
40 | $author->setName('...');
41 | $author->setEmail('...');
42 | $article->setAuthor($author);
43 |
44 | So, all that ``by_reference=false`` really does is that it clones the object,
45 | which enforces the framework to call the setter on the parent object.
46 |
47 | Similarly, if you're using the :doc:`CollectionType `
48 | field where your underlying collection data is an object (like with
49 | Doctrine's ``ArrayCollection``), then ``by_reference`` must be set to ``false``
50 | if you need the adder and remover (e.g. ``addAuthor()`` and ``removeAuthor()``)
51 | to be called.
52 |
--------------------------------------------------------------------------------
/reference/forms/types/options/checkbox_compound.rst.inc:
--------------------------------------------------------------------------------
1 | ``compound``
2 | ~~~~~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``false``
5 |
6 | This option specifies if a form is compound. As it's not the case for checkbox,
7 | by default, the value is overridden with the ``false`` value.
8 |
--------------------------------------------------------------------------------
/reference/forms/types/options/checkbox_empty_data.rst.inc:
--------------------------------------------------------------------------------
1 | ``empty_data``
2 | ~~~~~~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: ``mixed``
5 |
6 | This option determines what value the field will return when the ``placeholder``
7 | choice is selected. In the checkbox and the radio type, the value of ``empty_data``
8 | is overridden by the value returned by the data transformer (see :doc:`/form/data_transformers`).
9 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_attr.rst.inc:
--------------------------------------------------------------------------------
1 | ``choice_attr``
2 | ~~~~~~~~~~~~~~~
3 |
4 | **type**: ``array``, ``callable``, ``string`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: ``[]``
5 |
6 | Use this to add additional HTML attributes to each choice. This can be
7 | an associative array where the keys match the choice keys and the values
8 | are the attributes for each choice, a callable or a property path
9 | (just like `choice_label`_).
10 |
11 | If an array, the keys of the ``choices`` array must be used as keys::
12 |
13 | use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
14 | // ...
15 |
16 | $builder->add('attending', ChoiceType::class, [
17 | 'choices' => [
18 | 'Yes' => true,
19 | 'No' => false,
20 | 'Maybe' => null,
21 | ],
22 | 'choice_attr' => function($choice, $key, $value) {
23 | // adds a class like attending_yes, attending_no, etc
24 | return ['class' => 'attending_'.strtolower($key)];
25 | },
26 | ]);
27 |
28 | .. tip::
29 |
30 | When defining a custom type, you should use the
31 | :class:`Symfony\\Component\\Form\\ChoiceList\\ChoiceList` class helper::
32 |
33 | use App\Entity\Category;
34 | use Symfony\Component\Form\ChoiceList\ChoiceList;
35 |
36 | // ...
37 | $builder->add('choices', ChoiceType::class, [
38 | 'choice_label' => ChoiceList::attr($this, function (?Category $category) {
39 | return $category ? ['data-uuid' => $category->getUuid()] : [];
40 | }),
41 | ]);
42 |
43 | See the :ref:`"choice_loader" option documentation `.
44 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_name.rst.inc:
--------------------------------------------------------------------------------
1 | ``choice_name``
2 | ~~~~~~~~~~~~~~~
3 |
4 | **type**: ``callable``, ``string`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: ``null``
5 |
6 | Controls the internal field name of the choice. You normally don't care about this,
7 | but in some advanced cases, you might. For example, this "name" becomes the index
8 | of the choice views in the template and is used as part of the field name
9 | attribute.
10 |
11 | This can be a callable or a property path. See `choice_label`_ for similar usage.
12 | By default, the choice key or an incrementing integer may be used (starting at ``0``).
13 |
14 | .. tip::
15 |
16 | When defining a custom type, you should use the
17 | :class:`Symfony\\Component\\Form\\ChoiceList\\ChoiceList` class helper::
18 |
19 | use Symfony\Component\Form\ChoiceList\ChoiceList;
20 |
21 | // ...
22 | $builder->add('choices', ChoiceType::class, [
23 | 'choice_name' => ChoiceList::fieldName($this, 'name'),
24 | ]);
25 |
26 | See the :ref:`"choice_loader" option documentation `.
27 |
28 | .. caution::
29 |
30 | The configured value must be a valid form name. Make sure to only return
31 | valid names when using a callable. Valid form names must be composed of
32 | letters, digits, underscores, dashes and colons and must not start with
33 | a dash or a colon.
34 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_translation_domain.rst.inc:
--------------------------------------------------------------------------------
1 | ``choice_translation_domain``
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``string``, ``boolean`` or ``null``
5 |
6 | This option determines if the choice values should be translated and in which
7 | translation domain.
8 |
9 | The values of the ``choice_translation_domain`` option can be ``true`` (reuse the current
10 | translation domain), ``false`` (disable translation), ``null`` (uses the parent translation
11 | domain or the default domain) or a string which represents the exact translation
12 | domain to use.
13 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_translation_locale.rst.inc:
--------------------------------------------------------------------------------
1 | choice_translation_locale
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``string`` or ``null`` **default**: ``null``
5 |
6 | This option determines if the choice values should be translated into a different locale
7 | than the current one.
8 |
9 | The values of the ``choice_translation_locale`` option can be ``null`` (reuse the current
10 | translation locale) or a string which represents the exact translation locale to use.
11 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_type_translation_domain.rst.inc:
--------------------------------------------------------------------------------
1 | translation_domain
2 | ~~~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``string`` **default**: ``messages``
5 |
6 | In case `choice_translation_domain`_ is set to ``true`` or ``null``, this
7 | configures the exact translation domain that will be used for any labels or
8 | options that are rendered for this field.
9 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_type_trim.rst.inc:
--------------------------------------------------------------------------------
1 | ``trim``
2 | ~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``false``
5 |
6 | Trimming is disabled by default because the selected value or values must match
7 | the given choice values exactly (and they could contain whitespaces).
8 |
--------------------------------------------------------------------------------
/reference/forms/types/options/choice_value.rst.inc:
--------------------------------------------------------------------------------
1 | ``choice_value``
2 | ~~~~~~~~~~~~~~~~
3 |
4 | **type**: ``callable``, ``string`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: ``null``
5 |
6 | Returns the string "value" for each choice, which must be unique across all choices.
7 | This is used in the ``value`` attribute in HTML and submitted in the POST/PUT requests.
8 | You don't normally need to worry about this, but it might be handy when processing
9 | an API request (since you can configure the value that will be sent in the API request).
10 |
11 | This can be a callable or a property path. By default, the choices are used if they
12 | can be casted to strings. Otherwise an incrementing integer is used (starting at ``0``).
13 |
14 | If you pass a callable, it will receive one argument: the choice itself. When using
15 | the :doc:`/reference/forms/types/entity`, the argument will be the entity object
16 | for each choice or ``null`` in a placeholder is used, which you need to handle::
17 |
18 | 'choice_value' => function (?MyOptionEntity $entity) {
19 | return $entity ? $entity->getId() : '';
20 | },
21 |
22 | .. tip::
23 |
24 | When defining a custom type, you should use the
25 | :class:`Symfony\\Component\\Form\\ChoiceList\\ChoiceList` class helper::
26 |
27 | use Symfony\Component\Form\ChoiceList\ChoiceList;
28 |
29 | // ...
30 | $builder->add('choices', ChoiceType::class, [
31 | 'choice_value' => ChoiceList::value($this, 'uuid'),
32 | ]);
33 |
34 | See the :ref:`"choice_loader" option documentation `.
35 |
--------------------------------------------------------------------------------
/reference/forms/types/options/compound.rst.inc:
--------------------------------------------------------------------------------
1 | ``compound``
2 | ~~~~~~~~~~~~
3 |
4 | **type**: ``boolean`` **default**: ``true``
5 |
6 | A compound form can be either an entire ``