@@ -324,8 +324,8 @@ you can control. The following configuration options exist for a mapping:
324
324
type
325
325
....
326
326
327
- One of ``annotation ``, ``xml ``, ``yml ``, ``php `` or ``staticphp ``. This specifies
328
- which type of metadata type your mapping uses.
327
+ One of ``annotation ``, ``xml ``, ``yml ``, ``php `` or ``staticphp ``. This
328
+ specifies which type of metadata type your mapping uses.
329
329
330
330
dir
331
331
...
@@ -339,27 +339,27 @@ that exist in the DIC (for example ``%kernel.root_dir%``).
339
339
prefix
340
340
......
341
341
342
- A common namespace prefix that all entities of this mapping share. This prefix
343
- should never conflict with prefixes of other defined mappings otherwise some
344
- of your entities cannot be found by Doctrine. This option defaults to the
345
- bundle namespace + ``Entity ``, for example for an application bundle called
346
- AcmeHelloBundle prefix would be ``Acme\HelloBundle\Entity ``.
342
+ A common namespace prefix that all entities of this mapping share. This
343
+ prefix should never conflict with prefixes of other defined mappings otherwise
344
+ some of your entities cannot be found by Doctrine. This option defaults
345
+ to the bundle namespace + ``Entity ``, for example for an application bundle
346
+ called AcmeHelloBundle prefix would be ``Acme\HelloBundle\Entity ``.
347
347
348
348
alias
349
349
.....
350
350
351
351
Doctrine offers a way to alias entity namespaces to simpler, shorter names
352
- to be used in DQL queries or for Repository access. When using a bundle the
353
- alias defaults to the bundle name.
352
+ to be used in DQL queries or for Repository access. When using a bundle
353
+ the alias defaults to the bundle name.
354
354
355
355
is_bundle
356
356
.........
357
357
358
358
This option is a derived value from ``dir `` and by default is set to ``true ``
359
359
if dir is relative proved by a ``file_exists() `` check that returns ``false ``.
360
360
It is ``false `` if the existence check returns ``true ``. In this case an
361
- absolute path was specified and the metadata files are most likely in a directory
362
- outside of a bundle.
361
+ absolute path was specified and the metadata files are most likely in a
362
+ directory outside of a bundle.
363
363
364
364
.. index ::
365
365
single: Configuration; Doctrine DBAL
@@ -448,14 +448,15 @@ The following block shows all possible configuration keys:
448
448
449
449
.. note ::
450
450
451
- The ``server_version `` option was added in Doctrine DBAL 2.5, which is used
452
- by DoctrineBundle 1.3. The value of this option should match your database
453
- server version (use ``postgres -V `` or ``psql -V `` command to find
454
- your PostgreSQL version and ``mysql -V `` to get your MySQL version).
451
+ The ``server_version `` option was added in Doctrine DBAL 2.5, which
452
+ is used by DoctrineBundle 1.3. The value of this option should match
453
+ your database server version (use ``postgres -V `` or ``psql -V `` command
454
+ to find your PostgreSQL version and ``mysql -V `` to get your MySQL
455
+ version).
455
456
456
- If you don't define this option and you haven't created your database yet,
457
- you may get ``PDOException `` errors because Doctrine will try to guess the
458
- database server version automatically and none is available.
457
+ If you don't define this option and you haven't created your database
458
+ yet, you may get ``PDOException `` errors because Doctrine will try to
459
+ guess the database server version automatically and none is available.
459
460
460
461
If you want to configure multiple connections in YAML, put them under the
461
462
``connections `` key and give them a unique name:
@@ -524,24 +525,26 @@ Keep in mind that you can't use both syntaxes at the same time.
524
525
Custom Mapping Entities in a Bundle
525
526
-----------------------------------
526
527
527
- Doctrine's ``auto_mapping `` feature loads annotation configuration from the
528
- ``Entity/ `` directory of each bundle *and * looks for other formats (e.g. YAML, XML)
529
- in the ``Resources/config/doctrine `` directory.
528
+ Doctrine's ``auto_mapping `` feature loads annotation configuration from
529
+ the ``Entity/ `` directory of each bundle *and * looks for other formats (e.g.
530
+ YAML, XML) in the ``Resources/config/doctrine `` directory.
530
531
531
- If you store metadata somewhere else in your bundle, you can define your own mappings,
532
- where you tell Doctrine exactly *where * to look, along with some other configurations.
532
+ If you store metadata somewhere else in your bundle, you can define your
533
+ own mappings, where you tell Doctrine exactly *where * to look, along with
534
+ some other configurations.
533
535
534
- If you're using the ``auto_mapping `` configuration, you just need to overwrite the
535
- configurations you want. In this case it's important that the key of the mapping
536
- configurations corresponds to the name of the bundle.
536
+ If you're using the ``auto_mapping `` configuration, you just need to overwrite
537
+ the configurations you want. In this case it's important that the key of
538
+ the mapping configurations corresponds to the name of the bundle.
537
539
538
- For example, suppose you decide to store your ``XML `` configuration for ``AppBundle `` entities
539
- in the ``@AppBundle/SomeResources/config/doctrine `` directory instead:
540
+ For example, suppose you decide to store your ``XML `` configuration for
541
+ ``AppBundle `` entities in the ``@AppBundle/SomeResources/config/doctrine ``
542
+ directory instead:
540
543
541
544
.. configuration-block ::
542
545
543
546
.. code-block :: yaml
544
-
547
+
545
548
doctrine :
546
549
# ...
547
550
orm :
@@ -552,22 +555,22 @@ in the ``@AppBundle/SomeResources/config/doctrine`` directory instead:
552
555
AppBundle :
553
556
type : xml
554
557
dir : SomeResources/config/doctrine
555
-
558
+
556
559
.. code-block :: xml
557
-
560
+
558
561
<?xml version =" 1.0" charset =" UTF-8" ?>
559
562
<container xmlns =" http://symfony.com/schema/dic/services"
560
563
xmlns : doctrine =" http://symfony.com/schema/dic/doctrine" >
561
-
564
+
562
565
<doctrine : config >
563
566
<doctrine : orm auto-mapping =" true" >
564
567
<mapping name =" AppBundle" dir =" SomeResources/config/doctrine" type =" xml" />
565
568
</doctrine : orm >
566
569
</doctrine : config >
567
570
</container >
568
-
571
+
569
572
.. code-block :: php
570
-
573
+
571
574
$container->loadFromExtension('doctrine', array(
572
575
'orm' => array(
573
576
'auto_mapping' => true,
@@ -582,13 +585,14 @@ Mapping Entities Outside of a Bundle
582
58
F987
5
583
586
You can also create new mappings, for example outside of the Symfony folder.
584
587
585
- For example, the following looks for entity classes in the ``App\Entity `` namespace in the
586
- ``src/Entity `` directory and gives them an ``App `` alias (so you can say things like ``App:Post ``):
588
+ For example, the following looks for entity classes in the ``App\Entity ``
589
+ namespace in the ``src/Entity `` directory and gives them an ``App `` alias
590
+ (so you can say things like ``App:Post ``):
587
591
588
592
.. configuration-block ::
589
593
590
594
.. code-block :: yaml
591
-
595
+
592
596
doctrine :
593
597
# ...
594
598
orm :
@@ -601,16 +605,16 @@ For example, the following looks for entity classes in the ``App\Entity`` namesp
601
605
is_bundle : false
602
606
prefix : App\Entity
603
607
alias : App
604
-
608
+
605
609
.. code-block :: xml
606
-
610
+
607
611
<?xml version =" 1.0" charset =" UTF-8" ?>
608
612
<container xmlns =" http://symfony.com/schema/dic/services"
609
613
xmlns : doctrine =" http://symfony.com/schema/dic/doctrine" >
610
-
614
+
611
615
<doctrine : config >
612
616
<doctrine : orm >
613
- <mapping name =" SomeEntityNamespace"
617
+ <mapping name =" SomeEntityNamespace"
614
618
type =" annotation"
615
619
dir =" %kernel.root_dir%/../src/Entity"
616
620
is-bundle =" false"
@@ -620,9 +624,9 @@ For example, the following looks for entity classes in the ``App\Entity`` namesp
620
624
</doctrine : orm >
621
625
</doctrine : config >
622
626
</container >
623
-
627
+
624
628
.. code-block :: php
625
-
629
+
626
630
$container->loadFromExtension('doctrine', array(
627
631
'orm' => array(
628
632
'auto_mapping' => true,
@@ -641,31 +645,33 @@ For example, the following looks for entity classes in the ``App\Entity`` namesp
641
645
Detecting a Mapping Configuration Format
642
646
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
643
647
644
- If the ``type `` on the bundle configuration isn't set,
645
- the DoctrineBundle will try to detect the correct mapping configuration format for
646
- the bundle.
648
+ If the ``type `` on the bundle configuration isn't set, the DoctrineBundle
649
+ will try to detect the correct mapping configuration format for the bundle.
647
650
648
- DoctrineBundle will look for files matching ``*.orm.[FORMAT] `` (e.g. `` Post.orm.yml ``)
649
- in the configured ``dir `` of your mapping (if you're mapping a bundle, then `` dir `` is
650
- relative to the bundle's directory).
651
+ DoctrineBundle will look for files matching ``*.orm.[FORMAT] `` (e.g.
652
+ `` Post.orm.yml ``) in the configured ``dir `` of your mapping (if you're mapping
653
+ a bundle, then `` dir `` is relative to the bundle's directory).
651
654
652
655
The bundle looks for (in this order) XML, YAML and PHP files.
653
- Using the ``auto_mapping `` feature, every bundle can have only one configuration format.
654
- The bundle will stop as soon as it locates one.
656
+ Using the ``auto_mapping `` feature, every bundle can have only one
657
+ configuration format. The bundle will stop as soon as it locates one.
655
658
656
659
If it wasn't possible to determine a configuration format for a bundle,
657
- the DoctrineBundle will check if there is an ``Entity `` folder in the bundle's root directory.
658
- If the folder exist, Doctrine will fall back to using an annotation driver.
660
+ the DoctrineBundle will check if there is an ``Entity `` folder in the bundle's
661
+ root directory. If the folder exist, Doctrine will fall back to using an
662
+ annotation driver.
659
663
660
- Default Value of dir
664
+ Default Value of Dir
661
665
~~~~~~~~~~~~~~~~~~~~
662
666
663
- If ``dir `` is not specified, then its default value depends on which configuration driver is being used.
664
- For drivers that rely on the PHP files (annotation, staticphp) it will
665
- be ``[Bundle]/Entity ``. For drivers that are using configuration
666
- files (XML, YAML, ...) it will be ``[Bundle]/Resources/config/doctrine ``.
667
+ If ``dir `` is not specified, then its default value depends on which configuration
668
+ driver is being used. For drivers that rely on the PHP files (annotation,
669
+ staticphp) it will be ``[Bundle]/Entity ``. For drivers that are using
670
+ configuration files (XML, YAML, ...) it will be
671
+ ``[Bundle]/Resources/config/doctrine ``.
667
672
668
- If the ``dir `` configuration is set and the ``is_bundle `` configuration is ``true ``,
669
- the DoctrineBundle will prefix the ``dir `` configuration with the path of the bundle.
673
+ If the ``dir `` configuration is set and the ``is_bundle `` configuration
674
+ is ``true ``, the DoctrineBundle will prefix the ``dir `` configuration with
675
+ the path of the bundle.
670
676
671
677
.. _`DQL User Defined Functions` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-user-defined-functions.html
0 commit comments