8000 minor #8643 Updated reference articles to Symfony 4 (javiereguiluz) · symfony/symfony-docs@fef815b · GitHub
[go: up one dir, main page]

Skip to content

Commit fef815b

Browse files
committed
minor #8643 Updated reference articles to Symfony 4 (javiereguiluz)
This PR was squashed before being merged into the 4.0 branch (closes #8643 10000 ). Discussion ---------- Updated reference articles to Symfony 4 This fixes #8642. ----- I want to update these two files more deeply in a separate PR, so here their changes are minimal: * `reference/events.rst` * `reference/dic_tags.rst` ----- Now, some questions: **1)** I've moved all custom Doctrine clases (custom DQL functions, custom DBAL types, custom database drivers, etc.) under `App\Bridge\Doctrine\` namespace (e.g. `Acme\HelloBundle\DQL\DatetimeFunction` -> `App\Bridge\Doctrine\DQL\DatetimeFunction`). I saw this in a Symfony app and I like it. Do you agree? **2)** I don't know how to update this section from `/reference/configuration/framework.rst`: ```rst resources """"""""" **type**: ``string[]`` **default**: ``['FrameworkBundle:Form']`` A list of all resources for form theming in PHP. This setting is not required if you're using the Twig format for your templates, in that case refer to :ref:`the form article <forms-theming-twig>`. Assume you have custom global form themes in ``src/Resources/views/Form``, you can configure this like: .. configuration-block:: .. code-block:: yaml # config/packages/framework.yaml framework: templating: form: resources: - 'WebsiteBundle:Form' [...] .. note:: The default form templates from ``FrameworkBundle:Form`` will always be included in the form resources. .. seealso:: See :ref:`forms-theming-global` for more information. ``` **3)** The `reference/configuration/doctrine.rst` contains A LOT of references to bundles, including options designed for bundles (`prefix`, `alias`, `is_bundle`) What should we do? * Remove all references to bundles, including those options? * Maintain all those options but update their explanations using the default Symfony Flex Recipe config? (see https://github.com/symfony/recipes/blob/db32040b48e9cf15299e7702a75a49e76999ff3f/doctrine/doctrine-bundle/1.6/config/packages/doctrine.yaml#L9-L15) * ...? Commits ------- f709035 Restored the Assetic tags because they are removed in another PR 206bf70 Updated Doctrine config reference about bundles e80995b Fixed PHP form theme resources ef2a044 Remove App\Bridge\Doctrine\ namespace da67105 Updated reference articles to Symfony 4
2 parents 59f5e18 + f709035 commit fef815b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+218
-343
lines changed

reference/configuration/assetic.rst

Lines changed: 4 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,119 +4,8 @@
44
AsseticBundle Configuration ("assetic")
55
=======================================
66

7-
.. include:: /assetic/_standard_edition_warning.rst.inc
7+
.. caution::
88

9-
Full Default Configuration
10-
--------------------------
11-
12-
.. configuration-block::
13-
14-
.. code-block:: yaml
15-
16-
# app/config/config.yml
17-
assetic:
18-
debug: '%kernel.debug%'
19-
use_controller:
20-
enabled: '%kernel.debug%'
21-
profiler: false
22-
read_from: '%assetic.read_from%'
23-
write_to: '%kernel.project_dir%/web'
24-
java: /usr/bin/java
25-
node: /usr/bin/node
26-
ruby: /usr/bin/ruby
27-
sass: /usr/bin/sass
28-
# An key-value pair of any number of named elements
29-
variables:
30-
some_name: []
31-
bundles:
32-
33-
# Defaults (all currently registered bundles):
34-
- FrameworkBundle
35-
- SecurityBundle
36-
- TwigBundle
37-
- MonologBundle
38-
- SwiftmailerBundle
39-
- DoctrineBundle
40-
- AsseticBundle
41-
- ...
42-
assets:
43-
# An array of named assets (e.g. some_asset, some_other_asset)
44-
some_asset:
45-
inputs: []
46-
filters: []
47-
options:
48-
# A key-value array of options and values
49-
some_option_name: []
50-
filters:
51-
52-
# An array of named filters (e.g. some_filter, some_other_filter)
53-
some_filter: []
54-
workers:
55-
# see https://github.com/symfony/AsseticBundle/pull/119
56-
# Cache can also be busted via the framework.assets.version
57-
# setting - see the "framework" configuration section
58-
cache_busting:
59-
enabled: false
60-
twig:
61-
functions:
62-
# An array of named functions (e.g. some_function, some_other_function)
63-
some_function: []
64-
65-
.. code-block:: xml
66-
67-
<!-- app/config/config.xml -->
68-
<?xml version="1.0" encoding="UTF-8"?>
69-
<container xmlns="http://symfony.com/schema/dic/services"
70-
xmlns:assetic="http://symfony.com/schema/dic/assetic"
71-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
72-
xsi:schemaLocation="http://symfony.com/schema/dic/services
73-
http://symfony.com/schema/dic/services/services-1.0.xsd
74-
http://symfony.com/schema/dic/assetic
75-
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">
76-
77-
<assetic:config
78-
debug="%kernel.debug%"
79-
use-controller="%kernel.debug%"
80-
read-from="%assetic.read_from%"
81-
write-to="%kernel.project_dir%/web"
82-
java="/usr/bin/java"
83-
node="/usr/bin/node"
84-
sass="/usr/bin/sass">
85-
86-
<!-- Defaults (all currently registered bundles) -->
87-
<assetic:bundle>FrameworkBundle</assetic:bundle>
88-
<assetic:bundle>SecurityBundle</assetic:bundle>
89-
<assetic:bundle>TwigBundle</assetic:bundle>
90-
<assetic:bundle>MonologBundle</assetic:bundle>
91-
<assetic:bundle>SwiftmailerBundle</assetic:bundle>
92-
<assetic:bundle>DoctrineBundle</assetic:bundle>
93-
<assetic:bundle>AsseticBundle</assetic:bundle>
94-
<assetic:bundle>...</assetic:bundle>
95-
96-
<assetic:asset>
97-
<!-- prototype -->
98-
<assetic:name>
99-
<assetic:input />
100-
101-
<assetic:filter />
102-
103-
<assetic:option>
104-
<!-- prototype -->
105-
<assetic:name />
106-
</assetic:option>
107-
</assetic:name>
108-
</assetic:asset>
109-
110-
<assetic:filter>
111-
<!-- prototype -->
112-
<assetic:name />
113-
</assetic:filter>
114-
115-
<assetic:twig>
116-
<assetic:functions>
117-
<!-- prototype -->
118-
<assetic:name />
119-
</assetic:functions>
120-
</assetic:twig>
121-
</assetic:config>
122-
</container>
9+
Assetic is no longer recommended to manage web assets in Symfony
10+
applications. Instead, use :doc:`Webpack Encore </frontend>`, which bridges
11+
Symfony applications with modern JavaScript tools used to manage web assets.

reference/configuration/debug.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ destination for dumps. Typically, you would set this to ``php://stderr``:
6464

6565
.. code-block:: yaml
6666
67-
# app/config/config.yml
67+
# config/packages/debug.yaml
6868
debug:
6969
dump_destination: php://stderr
7070
7171
.. code-block:: xml
7272
73-
<!-- app/config/config.xml -->
73+
<!-- config/packages/debug.xml -->
7474
<?xml version="1.0" encoding="UTF-8" ?>
7575
<container xmlns="http://symfony.com/schema/dic/debug"
7676
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -84,7 +84,7 @@ destination for dumps. Typically, you would set this to ``php://stderr``:
8484
8585
.. code-block:: php
8686
87-
// app/config/config.php
87+
// config/packages/debug.php
8888
$container->loadFromExtension('debug', array(
8989
'dump_destination' => 'php://stderr 10000 ',
9090
));

reference/configuration/doctrine.rst

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Full Default Configuration
1212

1313
.. code-block:: yaml
1414
15-
# app/config/config.yml
15+
# config/packages/doctrine.yaml
1616
doctrine:
1717
dbal:
1818
default_connection: default
1919
types:
2020
# A collection of custom types
2121
# Example
2222
some_custom_type:
23-
class: Acme\HelloBundle\MyCustomType
23+
class: App\DBAL\MyCustomType
2424
commented: true
25-
25+
2626
2727
connections:
2828
# A collection of different named connections (e.g. default, conn2, etc)
@@ -75,11 +75,11 @@ Full Default Configuration
7575
mapping_types:
7676
# an array of mapping types
7777
name: []
78-
78+
7979
# If defined, only the tables whose names match this regular expression are managed
8080
# by the schema tool (in this example, any table name not starting with `wp_`)
8181
#schema_filter: '/^(?!wp_)/'
82-
82+
8383
slaves:
8484
8585
# a collection of named slave connections (e.g. slave1, slave2)
@@ -163,17 +163,17 @@ Full Default Configuration
163163
# a collection of string functions
164164
string_functions:
165165
# example
166-
# test_string: Acme\HelloBundle\DQL\StringFunction
166+
# test_string: App\DQL\StringFunction
167167
168168
# a collection of numeric functions
169169
numeric_functions:
170170
# example
171-
# test_numeric: Acme\HelloBundle\DQL\NumericFunction
171+
# test_numeric: App\DQL\NumericFunction
172172
173173
# a collection of datetime functions
174174
datetime_functions:
175175
# example
176-
# test_datetime: Acme\HelloBundle\DQL\DatetimeFunction
176+
# test_datetime: App\DQL\DatetimeFunction
177177
178178
# Register SQL Filters in the entity manager
179179
filters:
@@ -184,7 +184,7 @@ Full Default Configuration
184184
185185
.. code-block:: xml
186186
187-
<!-- app/config/config.xml -->
187+
<!-- config/packages/doctrine.xml -->
188188
<?xml version="1.0" encoding="UTF-8" ?>
189189
<container xmlns="http://symfony.com/schema/dic/services"
190190
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -204,22 +204,22 @@ Full Default Configuration
204204
user="user"
205205
password="secret"
206206
driver="pdo_mysql"
207-
driver-class="MyNamespace\MyDriverImpl"
207+
driver-class="App\DBAL\MyDatabaseDriver"
208208
path="%kernel.project_dir%/var/data/data.sqlite"
209209
memory="true"
210210
unix-socket="/tmp/mysql.sock"
211-
wrapper-class="MyDoctrineDbalConnectionWrapper"
211+
wrapper-class="App\DBAL\MyConnectionWrapper"
212212
charset="UTF8"
213213
logging="%kernel.debug%"
214-
platform-service="MyOwnDatabasePlatformService"
214+
platform-service="App\DBAL\MyDatabasePlatformService"
215215
server-version="5.6"
216216
keep-slave="false"
217217
>
218218
<doctrine:option key="foo">bar</doctrine:option>
219219
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
220220
</doctrine:connection>
221221
<doctrine:connection name="conn1" />
222-
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
222+
<doctrine:type name="custom">App\DBAL\MyCustomType</doctrine:type>
223223
</doctrine:dbal>
224224
225225
<doctrine:orm
@@ -247,15 +247,15 @@ Full Default Configuration
247247
248248
<doctrine:dql>
249249
<doctrine:string-function name="test_string">
250-
Acme\HelloBundle\DQL\StringFunction
250+
App\DQL\StringFunction
251251
</doctrine:string-function>
252252
253253
<doctrine:numeric-function name="test_numeric">
254-
Acme\HelloBundle\DQL\NumericFunction
254+
App\DQL\NumericFunction
255255
</doctrine:numeric-function>
256256
257257
<doctrine:datetime-function name="test_datetime">
258-
Acme\HelloBundle\DQL\DatetimeFunction
258+
App\DQL\DatetimeFunction
259259
</doctrine:datetime-function>
260260
</doctrine:dql>
261261
</doctrine:entity-manager>
@@ -301,23 +301,23 @@ The following block shows all possible configuration keys:
301301
password: secret
302302
driver: pdo_mysql
303303
# the DBAL driverClass option
304-
driver_class: MyNamespace\MyDriverImpl
304+
driver_class: App\DBAL\MyDatabaseDriver
305305
# the DBAL driverOptions option
306306
options:
307307
foo: bar
308308
path: '%kernel.project_dir%/app/data/data.sqlite'
309309
memory: true
310310
unix_socket: /tmp/mysql.sock
311311
# the DBAL wrapperClass option
312-
wrapper_class: MyDoctrineDbalConnectionWrapper
312+
wrapper_class: App\DBAL\MyConnectionWrapper
313313 10000
charset: UTF8
314314
logging: '%kernel.debug%'
315-
platform_service: MyOwnDatabasePlatformService
315+
platform_service: App\DBAL\MyDatabasePlatformService
316316
server_version: 5.6
317317
mapping_types:
318318
enum: string
319319
types:
320-
custom: Acme\HelloBundle\MyCustomType
320+
custom: App\DBAL\MyCustomType
321321
322322
.. code-block:: xml
323323
@@ -339,19 +339,19 @@ The following block shows all possible configuration keys:
339339
user="user"
340340
password="secret"
341341
driver="pdo_mysql"
342-
driver-class="MyNamespace\MyDriverImpl"
342+
driver-class="App\DBAL\MyDatabaseDriver"
343343
path="%kernel.project_dir%/var/data/data.sqlite"
344344
memory="true"
345345
unix-socket="/tmp/mysql.sock"
346-
wrapper-class="MyDoctrineDbalConnectionWrapper"
346+
wrapper-class="App\DBAL\MyConnectionWrapper"
347347
charset="UTF8"
348348
logging="%kernel.debug%"
349-
platform-service="MyOwnDatabasePlatformService"
349+
platform-service="App\DBAL\MyDatabasePlatformService"
350350
server-version="5.6">
351351
352352
<doctrine:option key="foo">bar</doctrine:option>
353353
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
354-
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
354+
<doctrine:type name="custom">App\DBAL\MyCustomType</doctrine:type>
355355
</doctrine:dbal>
356356
</doctrine:config>
357357
</container>
@@ -480,7 +480,7 @@ The following example shows an overview of the caching configurations:
480480
# the 'service' type requires to define the 'id' option too
481481
query_cache_driver:
482482
type: service
483-
id: my_doctrine_common_cache_service
483+
id: App\ORM\MyCacheService
484484
485485
Mapping Configuration
486486
~~~~~~~~~~~~~~~~~~~~~
@@ -492,42 +492,35 @@ you can control. The following configuration options exist for a mapping:
492492
type
493493
....
494494

495-
One of ``annotation``, ``xml``, ``yml``, ``php`` or ``staticphp``. This
496-
specifies which type of metadata type your mapping uses.
495+
One of ``annotation`` (the default value), ``xml``, ``yml``, ``php`` or
496+
``staticphp``. This specifies which type of metadata type your mapping uses.
497497

498498
dir
499499
...
500500

501-
Path to the mapping or entity files (depending on the driver). If this path
502-
is relative it is assumed to be relative to the bundle root. This only works
503-
if the name of your mapping is a bundle name. If you want to use this option
504-
to specify absolute paths you should prefix the path with the kernel parameters
505-
that exist in the DIC (for example ``%kernel.project_dir%``).
501+
Absolute path to the mapping or entity files (depending on the driver). The
502+
default value is ``%kernel.project_dir%/src/Entity/``.
506503

507504
prefix
508505
......
509506

510-
A common namespace prefix that all entities of this mapping share. This
511-
prefix should never conflict with prefixes of other defined mappings otherwise
512-
some of your entities cannot be found by Doctrine. This option defaults
513-
to the bundle namespace + ``Entity``, for example for an application bundle
514-
called AcmeHelloBundle prefix would be ``Acme\HelloBundle\Entity``.
507+
A common namespace prefix that all entities of this mapping share. This prefix
508+
should never conflict with prefixes of other defined mappings otherwise some of
509+
your entities cannot be found by Doctrine. This option defaults to
510+
``App\Entity`` because it's recommended to store the entities in ``src/Entity/``.
515511

516512
alias
517513
.....
518514

519515
Doctrine offers a way to alias entity namespaces to simpler, shorter names
520-
to be used in DQL queries or for Repository access. When using a bundle
521-
the alias defaults to the bundle name.
516+
to be used in DQL queries or for Repository access. It's default value is ``App``.
522517

523518
is_bundle
524519
.........
525520

526-
This option is a derived value from ``dir`` and by default is set to ``true``
527-
if dir is relative proved by a ``file_exists()`` check that returns ``false``.
528-
It is ``false`` if the existence check returns ``true``. In this case an
529-
absolute path was specified and the metadata files are most likely in a
530-
directory outside of a bundle.
521+
This option is ``false`` by default and it's considered a legacy option. It was
522+
only useful in previous Symfony versions, when it was recommended to use bundles
523+
to organize the application code.
531524

532525
Custom Mapping Entities in a Bundle
533526
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -593,9 +586,7 @@ directory instead:
593586
Mapping Entities Outside of a Bundle
594587
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
595588

596-
You can also create new mappings, for example outside of the Symfony folder.
597-
598-
For example, the following looks for entity classes in the ``App\Entity``
589+
For example, the following looks for entity classes in the ``Entity``
599590
namespace in the ``src/Entity`` directory and gives them an ``App`` alias
600591
(so you can say things like ``App:Post``):
601592

@@ -662,7 +653,7 @@ If the ``type`` on the bundle configuration isn't set, the DoctrineBundle
662653
will try to detect the correct mapping configuration format for the bundle.
663654

664655
DoctrineBundle will look for files matching ``*.orm.[FORMAT]`` (e.g.
665-
``Post.orm.yml``) in the configured ``dir`` of your mapping (if you're mapping
656+
``Post.orm.yaml``) in the configured ``dir`` of your mapping (if you're mapping
666657
a bundle, then ``dir`` is relative to the bundle's directory).
667658

668659
The bundle looks for (in this order) XML, YAML and PHP files.

0 commit comments

Comments
 (0)
0