Skip to content

Updated reference articles to Symfony 4 #8643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 4 additions & 115 deletions reference/configuration/assetic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,119 +4,8 @@
AsseticBundle Configuration ("assetic")
=======================================

.. include:: /assetic/_standard_edition_warning.rst.inc
.. caution::

Full Default Configuration
--------------------------

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
assetic:
debug: '%kernel.debug%'
use_controller:
enabled: '%kernel.debug%'
profiler: false
read_from: '%assetic.read_from%'
write_to: '%kernel.project_dir%/web'
java: /usr/bin/java
node: /usr/bin/node
ruby: /usr/bin/ruby
sass: /usr/bin/sass
# An key-value pair of any number of named elements
variables:
some_name: []
bundles:

# Defaults (all currently registered bundles):
- FrameworkBundle
- SecurityBundle
- TwigBundle
- MonologBundle
- SwiftmailerBundle
- DoctrineBundle
- AsseticBundle
- ...
assets:
# An array of named assets (e.g. some_asset, some_other_asset)
some_asset:
inputs: []
filters: []
options:
# A key-value array of options and values
some_option_name: []
filters:

# An array of named filters (e.g. some_filter, some_other_filter)
some_filter: []
workers:
# see https://github.com/symfony/AsseticBundle/pull/119
# Cache can also be busted via the framework.assets.version
# setting - see the "framework" configuration section
cache_busting:
enabled: false
twig:
functions:
# An array of named functions (e.g. some_function, some_other_function)
some_function: []

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:assetic="http://symfony.com/schema/dic/assetic"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/assetic
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">

<assetic:config
debug="%kernel.debug%"
use-controller="%kernel.debug%"
read-from="%assetic.read_from%"
write-to="%kernel.project_dir%/web"
java="/usr/bin/java"
node="/usr/bin/node"
sass="/usr/bin/sass">

<!-- Defaults (all currently registered bundles) -->
<assetic:bundle>FrameworkBundle</assetic:bundle>
<assetic:bundle>SecurityBundle</assetic:bundle>
<assetic:bundle>TwigBundle</assetic:bundle>
<assetic:bundle>MonologBundle</assetic:bundle>
<assetic:bundle>SwiftmailerBundle</assetic:bundle>
<assetic:bundle>DoctrineBundle</assetic:bundle>
<assetic:bundle>AsseticBundle</assetic:bundle>
<assetic:bundle>...</assetic:bundle>

<assetic:asset>
<!-- prototype -->
<assetic:name>
<assetic:input />

<assetic:filter />

<assetic:option>
<!-- prototype -->
<assetic:name />
</assetic:option>
</assetic:name>
</assetic:asset>

<assetic:filter>
<!-- prototype -->
<assetic:name />
</assetic:filter>

<assetic:twig>
<assetic:functions>
<!-- prototype -->
<assetic:name />
</assetic:functions>
</assetic:twig>
</assetic:config>
</container>
Assetic is no longer recommended to manage web assets in Symfony
applications. Instead, use :doc:`Webpack Encore </frontend>`, which bridges
Symfony applications with modern JavaScript tools used to manage web assets.
6 changes: 3 additions & 3 deletions reference/configuration/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ destination for dumps. Typically, you would set this to ``php://stderr``:

.. code-block:: yaml

# app/config/config.yml
# config/packages/debug.yaml
debug:
dump_destination: php://stderr

.. code-block:: xml

<!-- app/config/config.xml -->
<!-- config/packages/debug.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/debug"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -84,7 +84,7 @@ destination for dumps. Typically, you would set this to ``php://stderr``:

.. code-block:: php

// app/config/config.php
// config/packages/debug.php
$container->loadFromExtension('debug', array(
'dump_destination' => 'php://stderr',
));
87 changes: 39 additions & 48 deletions reference/configuration/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ Full Default Configuration

.. code-block:: yaml

# app/config/config.yml
# config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: default
types:
# A collection of custom types
# Example
some_custom_type:
class: Acme\HelloBundle\MyCustomType
class: App\DBAL\MyCustomType
commented: true


connections:
# A collection of different named connections (e.g. default, conn2, etc)
Expand Down Expand Up @@ -75,11 +75,11 @@ Full Default Configuration
mapping_types:
# an array of mapping types
name: []

# If defined, only the tables whose names match this regular expression are managed
# by the schema tool (in this example, any table name not starting with `wp_`)
#schema_filter: '/^(?!wp_)/'

slaves:

# a collection of named slave connections (e.g. slave1, slave2)
Expand Down Expand Up @@ -163,17 +163,17 @@ Full Default Configuration
# a collection of string functions
string_functions:
# example
# test_string: Acme\HelloBundle\DQL\StringFunction
# test_string: App\DQL\StringFunction

# a collection of numeric functions
numeric_functions:
# example
# test_numeric: Acme\HelloBundle\DQL\NumericFunction
# test_numeric: App\DQL\NumericFunction

# a collection of datetime functions
datetime_functions:
# example
# test_datetime: Acme\HelloBundle\DQL\DatetimeFunction
# test_datetime: App\DQL\DatetimeFunction

# Register SQL Filters in the entity manager
filters:
Expand All @@ -184,7 +184,7 @@ Full Default Configuration

.. code-block:: xml

<!-- app/config/config.xml -->
<!-- config/packages/doctrine.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -204,22 +204,22 @@ Full Default Configuration
user="user"
password="secret"
driver="pdo_mysql"
driver-class="MyNamespace\MyDriverImpl"
driver-class="App\DBAL\MyDatabaseDriver"
path="%kernel.project_dir%/var/data/data.sqlite"
memory="true"
unix-socket="/tmp/mysql.sock"
wrapper-class="MyDoctrineDbalConnectionWrapper"
wrapper-class="App\DBAL\MyConnectionWrapper"
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
platform-service="App\DBAL\MyDatabasePlatformService"
server-version="5.6"
keep-slave="false"
>
<doctrine:option key="foo">bar</doctrine:option>
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
</doctrine:connection>
<doctrine:connection name="conn1" />
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
<doctrine:type name="custom">App\DBAL\MyCustomType</doctrine:type>
</doctrine:dbal>

<doctrine:orm
Expand Down Expand Up @@ -247,15 +247,15 @@ Full Default Configuration

<doctrine:dql>
<doctrine:string-function name="test_string">
Acme\HelloBundle\DQL\StringFunction
App\DQL\StringFunction
</doctrine:string-function>

<doctrine:numeric-function name="test_numeric">
Acme\HelloBundle\DQL\NumericFunction
App\DQL\NumericFunction
</doctrine:numeric-function>

<doctrine:datetime-function name="test_datetime">
Acme\HelloBundle\DQL\DatetimeFunction
App\DQL\DatetimeFunction
</doctrine:datetime-function>
</doctrine:dql>
</doctrine:entity-manager>
Expand Down Expand Up @@ -301,23 +301,23 @@ The following block shows all possible configuration keys:
password: secret
driver: pdo_mysql
# the DBAL driverClass option
driver_class: MyNamespace\MyDriverImpl
driver_class: App\DBAL\MyDatabaseDriver
# the DBAL driverOptions option
options:
foo: bar
path: '%kernel.project_dir%/app/data/data.sqlite'
memory: true
unix_socket: /tmp/mysql.sock
# the DBAL wrapperClass option
wrapper_class: MyDoctrineDbalConnectionWrapper
wrapper_class: App\DBAL\MyConnectionWrapper
charset: UTF8
logging: '%kernel.debug%'
platform_service: MyOwnDatabasePlatformService
platform_service: App\DBAL\MyDatabasePlatformService
server_version: 5.6
mapping_types:
enum: string
types:
custom: Acme\HelloBundle\MyCustomType
custom: App\DBAL\MyCustomType

.. code-block:: xml

Expand All @@ -339,19 +339,19 @@ The following block shows all possible configuration keys:
user="user"
password="secret"
driver="pdo_mysql"
driver-class="MyNamespace\MyDriverImpl"
driver-class="App\DBAL\MyDatabaseDriver"
path="%kernel.project_dir%/var/data/data.sqlite"
memory="true"
unix-socket="/tmp/mysql.sock"
wrapper-class="MyDoctrineDbalConnectionWrapper"
wrapper-class="App\DBAL\MyConnectionWrapper"
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
platform-service="App\DBAL\MyDatabasePlatformService"
server-version="5.6">

<doctrine:option key="foo">bar</doctrine:option>
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
<doctrine:type name="custom">App\DBAL\MyCustomType</doctrine:type>
</doctrine:dbal>
</doctrine:config>
</container>
Expand Down Expand Up @@ -480,7 +480,7 @@ The following example shows an overview of the caching configurations:
# the 'service' type requires to define the 'id' option too
query_cache_driver:
type: service
id: my_doctrine_common_cache_service
id: App\ORM\MyCacheService

Mapping Configuration
~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -492,42 +492,35 @@ you can control. The following configuration options exist for a mapping:
type
....

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

dir
...

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

prefix
......

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

alias
.....

Doctrine offers a way to alias entity namespaces to simpler, shorter names
to be used in DQL queries or for Repository access. When using a bundle
the alias defaults to the bundle name.
to be used in DQL queries or for Repository access. It's default value is ``App``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I took out these "default value is". These aren't really the default values - it's just what you get out-of-the-box with the recipe. And I think if you're configuring these things, then you are clearly looking at your doctrine.yaml file, so you will see those values there I think not mentioning these is a bit less confusing.


is_bundle
.........

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

Custom Mapping Entities in a Bundle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -593,9 +586,7 @@ directory instead:
Mapping Entities Outside of a Bundle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also create new mappings, for example outside of the Symfony folder.

For example, the following looks for entity classes in the ``App\Entity``
For example, the following looks for entity classes in the ``Entity``
namespace in the ``src/Entity`` directory and gives them an ``App`` alias
(so you can say things like ``App:Post``):

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

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

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