Initial commit with Symfony 2.1+Vendors

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely
2012-07-01 09:52:20 +02:00
commit 082a0130c2
5381 changed files with 416709 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
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">
<parameters>
<parameter key="doctrine.dbal.logger.chain.class">Doctrine\DBAL\Logging\LoggerChain</parameter>
<parameter key="doctrine.dbal.logger.profiling.class">Doctrine\DBAL\Logging\DebugStack</parameter>
<parameter key="doctrine.dbal.logger.class">Symfony\Bridge\Doctrine\Logger\DbalLogger</parameter>
<parameter key="doctrine.dbal.configuration.class">Doctrine\DBAL\Configuration</parameter>
<parameter key="doctrine.data_collector.class">Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector</parameter>
<parameter key="doctrine.dbal.connection.event_manager.class">Symfony\Bridge\Doctrine\ContainerAwareEventManager</parameter>
<parameter key="doctrine.dbal.connection_factory.class">Doctrine\Bundle\DoctrineBundle\ConnectionFactory</parameter>
<parameter key="doctrine.dbal.events.mysql_session_init.class">Doctrine\DBAL\Event\Listeners\MysqlSessionInit</parameter>
<parameter key="doctrine.dbal.events.oracle_session_init.class">Doctrine\DBAL\Event\Listeners\OracleSessionInit</parameter>
<parameter key="doctrine.class">Doctrine\Bundle\DoctrineBundle\Registry</parameter>
<parameter key="doctrine.entity_managers" type="collection"></parameter>
<parameter key="doctrine.default_entity_manager"></parameter>
</parameters>
<services>
<service id="doctrine.dbal.logger.chain" class="%doctrine.dbal.logger.chain.class%" public="false" abstract="true">
<call method="addLogger">
<argument type="service" id="doctrine.dbal.logger" />
</call>
</service>
<service id="doctrine.dbal.logger.profiling" class="%doctrine.dbal.logger.profiling.class%" public="false" abstract="true" />
<service id="doctrine.dbal.logger" class="%doctrine.dbal.logger.class%" public="false">
<tag name="monolog.logger" channel="doctrine" />
<argument type="service" id="logger" on-invalid="null" />
<argument type="service" id="debug.stopwatch" on-invalid="null" />
</service>
<service id="data_collector.doctrine" class="%doctrine.data_collector.class%" public="false">
<tag name="data_collector" template="DoctrineBundle:Collector:db" id="db" />
<argument type="service" id="doctrine" />
</service>
<service id="doctrine.dbal.connection_factory" class="%doctrine.dbal.connection_factory.class%">
<argument>%doctrine.dbal.connection_factory.types%</argument>
</service>
<service id="doctrine.dbal.connection" class="stdClass" factory-service="doctrine.dbal.connection_factory" factory-method="createConnection" abstract="true" />
<service id="doctrine.dbal.connection.event_manager" class="%doctrine.dbal.connection.event_manager.class%" public="false" abstract="true">
<argument type="service" id="service_container" />
</service>
<service id="doctrine.dbal.connection.configuration" class="%doctrine.dbal.configuration.class%" public="false" abstract="true" />
<service id="doctrine" class="%doctrine.class%">
<argument type="service" id="service_container" />
<argument>%doctrine.connections%</argument>
<argument>%doctrine.entity_managers%</argument>
<argument>%doctrine.default_connection%</argument>
<argument>%doctrine.default_entity_manager%</argument>
</service>
</services>
</container>

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
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">
<parameters>
<parameter key="doctrine.orm.configuration.class">Doctrine\ORM\Configuration</parameter>
<parameter key="doctrine.orm.entity_manager.class">Doctrine\ORM\EntityManager</parameter>
<parameter key="doctrine.orm.manager_configurator.class">Doctrine\Bundle\DoctrineBundle\ManagerConfigurator</parameter>
<!-- cache -->
<parameter key="doctrine.orm.cache.array.class">Doctrine\Common\Cache\ArrayCache</parameter>
<parameter key="doctrine.orm.cache.apc.class">Doctrine\Common\Cache\ApcCache</parameter>
<parameter key="doctrine.orm.cache.memcache.class">Doctrine\Common\Cache\MemcacheCache</parameter>
<parameter key="doctrine.orm.cache.memcache_host">localhost</parameter>
<parameter key="doctrine.orm.cache.memcache_port">11211</parameter>
<parameter key="doctrine.orm.cache.memcache_instance.class">Memcache</parameter>
<parameter key="doctrine.orm.cache.memcached.class">Doctrine\Common\Cache\MemcachedCache</parameter>
<parameter key="doctrine.orm.cache.memcached_host">localhost</parameter>
<parameter key="doctrine.orm.cache.memcached_port">11211</parameter>
<parameter key="doctrine.orm.cache.memcached_instance.class">Memcached</parameter>
<parameter key="doctrine.orm.cache.xcache.class">Doctrine\Common\Cache\XcacheCache</parameter>
<!-- metadata -->
<parameter key="doctrine.orm.metadata.driver_chain.class">Doctrine\ORM\Mapping\Driver\DriverChain</parameter>
<parameter key="doctrine.orm.metadata.annotation.class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter>
<parameter key="doctrine.orm.metadata.xml.class">Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver</parameter>
<parameter key="doctrine.orm.metadata.yml.class">Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver</parameter>
<parameter key="doctrine.orm.metadata.php.class">Doctrine\ORM\Mapping\Driver\PHPDriver</parameter>
<parameter key="doctrine.orm.metadata.staticphp.class">Doctrine\ORM\Mapping\Driver\StaticPHPDriver</parameter>
<!-- cache warmer -->
<parameter key="doctrine.orm.proxy_cache_warmer.class">Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer</parameter>
<!-- form field factory guesser -->
<parameter key="form.type_guesser.doctrine.class">Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser</parameter>
<!-- validator -->
<parameter key="doctrine.orm.validator.unique.class">Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator</parameter>
<parameter key="doctrine.orm.validator_initializer.class">Symfony\Bridge\Doctrine\Validator\DoctrineInitializer</parameter>
<!-- security -->
<parameter key="doctrine.orm.security.user.provider.class">Symfony\Bridge\Doctrine\Security\User\EntityUserProvider</parameter>
<!-- listeners -->
<parameter key="doctrine.orm.listeners.resolve_target_entity.class">Doctrine\ORM\Tools\ResolveTargetEntityListener</parameter>
</parameters>
<services>
<!--- Annotation Metadata Reader Service -->
<service id="doctrine.orm.metadata.annotation_reader" alias="annotation_reader" public="false" />
<service id="doctrine.orm.proxy_cache_warmer" class="%doctrine.orm.proxy_cache_warmer.class%" public="false">
<tag name="kernel.cache_warmer" />
<argument type="service" id="doctrine" />
</service>
<service id="form.type_guesser.doctrine" class="%form.type_guesser.doctrine.class%">
<tag name="form.type_guesser" />
<argument type="service" id="doctrine" />
</service>
<service id="form.type.entity" class="Symfony\Bridge\Doctrine\Form\Type\EntityType">
<tag name="form.type" alias="entity" />
<argument type="service" id="doctrine" />
</service>
<service id="doctrine.orm.configuration" class="%doctrine.orm.configuration.class%" abstract="true" public="false" />
<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" factory-class="%doctrine.orm.entity_manager.class%" factory-method="create" abstract="true" />
<!-- The configurator cannot be a private service -->
<service id="doctrine.orm.manager_configurator.abstract" class="%doctrine.orm.manager_configurator.class%" abstract="true">
<argument type="collection" />
</service>
<!-- validator -->
<service id="doctrine.orm.validator.unique" class="%doctrine.orm.validator.unique.class%">
<tag name="validator.constraint_validator" alias="doctrine.orm.validator.unique" />
<argument type="service" id="doctrine" />
</service>
<service id="doctrine.orm.validator_initializer" class="%doctrine.orm.validator_initializer.class%">
<tag name="validator.initializer" />
<argument type="service" id="doctrine" />
</service>
<!-- security -->
<service id="doctrine.orm.security.user.provider" class="%doctrine.orm.security.user.provider.class%" abstract="true" public="false">
<argument type="service" id="doctrine" />
</service>
<!-- listeners -->
<service id="doctrine.orm.listeners.resolve_target_entity" class="%doctrine.orm.listeners.resolve_target_entity.class%" public="false" />
</services>
</container>

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://symfony.com/schema/dic/doctrine"
elementFormDefault="qualified">
<xsd:element name="config">
<xsd:complexType>
<xsd:all>
<xsd:element name="dbal" type="dbal" minOccurs="0" maxOccurs="1" />
<xsd:element name="orm" type="orm" minOccurs="0" maxOccurs="1" />
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:attributeGroup name="connection-config">
<xsd:attribute name="driver" type="xsd:string" />
<xsd:attribute name="driver-class" type="xsd:string" />
<xsd:attribute name="wrapper-class" type="xsd:string" />
<xsd:attribute name="platform-service" type="xsd:string" />
<xsd:attribute name="logging" type="xsd:string" default="false" />
<xsd:attribute name="profiling" type="xsd:string" default="false" />
<xsd:attributeGroup ref="driver-config" />
</xsd:attributeGroup>
<xsd:attributeGroup name="driver-config">
<xsd:attribute name="dbname" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="user" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
<xsd:attribute name="path" type="xsd:string" />
<xsd:attribute name="unix-socket" type="xsd:string" />
<xsd:attribute name="memory" type="xsd:boolean" />
<xsd:attribute name="charset" type="xsd:string" />
<xsd:attribute name="persistent" type="xsd:boolean" />
<xsd:attribute name="protocol" type="xsd:string" />
<xsd:attribute name="service" type="xsd:boolean" />
<xsd:attribute name="session-mode" type="xsd:string" />
<xsd:attribute name="pooled" type="xsd:boolean" />
<xsd:attribute name="multiple-active-result-sets" type="xsd:boolean" />
</xsd:attributeGroup>
<xsd:complexType name="dbal">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="connection" type="connection" />
<xsd:element name="type" type="type" />
<xsd:element name="option" type="option" />
<xsd:element name="mapping-type" type="mapping-type" />
<xsd:element name="slave" type="slave" />
</xsd:choice>
<xsd:attribute name="default-connection" type="xsd:string" />
<xsd:attributeGroup ref="connection-config" />
</xsd:complexType>
<xsd:complexType name="option">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="key" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="mapping-type">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="type">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="connection">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="option" type="option" />
<xsd:element name="mapping-type" type="mapping-type" />
<xsd:element name="slave" type="slave" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attributeGroup ref="connection-config" />
</xsd:complexType>
<xsd:complexType name="slave">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attributeGroup ref="driver-config" />
</xsd:complexType>
<xsd:complexType name="mapping">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="dir" type="xsd:string" />
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="prefix" type="xsd:string" />
<xsd:attribute name="is-bundle" type="xsd:boolean" />
</xsd:complexType>
<xsd:complexType name="orm">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="entity-manager" type="entity_manager" />
<xsd:element name="mapping" type="mapping" />
<xsd:element name="metadata-cache-driver" type="metadata_cache_driver" minOccurs="0" maxOccurs="1" />
<xsd:element name="dql" type="dql" minOccurs="0" maxOccurs="1" />
<xsd:element name="filter" type="filter" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="resolve-target-entity" type="resolve_target_entity" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="auto-mapping" type="xsd:string" />
<xsd:attribute name="default-entity-manager" type="xsd:string" />
<xsd:attribute name="default-connection" type="xsd:string" />
<xsd:attribute name="proxy-dir" type="xsd:string" />
<xsd:attribute name="proxy-namespace" type="xsd:string" />
<xsd:attribute name="auto-generate-proxy-classes" type="xsd:string" default="false" />
<xsd:attribute name="default-repository-class" type="xsd:string" />
<xsd:attribute name="result-cache-driver" type="xsd:string" />
<xsd:attribute name="metadata-cache-driver" type="xsd:string" />
<xsd:attribute name="query-cache-driver" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="resolve_target_entity">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="interface" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="metadata_cache_driver">
<xsd:all>
<xsd:element name="class" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="instance-class" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="entity_manager">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="mapping" type="mapping" />
<xsd:element name="metadata-cache-driver" type="metadata_cache_driver" minOccurs="0" maxOccurs="1" />
<xsd:element name="dql" type="dql" minOccurs="0" maxOccurs="1" />
<xsd:element name="hydrator" type="type" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="filter" type="filter" minOccurs="0" maxOccurs="unbounded" />
</xsd:choice>
<xsd:attribute name="auto-mapping" type="xsd:string" />
<xsd:attribute name="connection" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="default-repository-class" type="xsd:string" />
<xsd:attribute name="result-cache-driver" type="xsd:string" />
<xsd:attribute name="metadata-cache-driver" type="xsd:string" />
<xsd:attribute name="query-cache-driver" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="filter">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="dql">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="string-function" type="dql_function" />
<xsd:element name="numeric-function" type="dql_function" />
<xsd:element name="datetime-function" type="dql_function" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="dql_function">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>

View File

@@ -0,0 +1,305 @@
.. index::
single: Doctrine; ORM Configuration Reference
single: Configuration Reference; Doctrine ORM
Configuration Reference
=======================
.. configuration-block::
.. code-block:: yaml
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: database
host: localhost
port: 1234
user: user
password: secret
driver: pdo_mysql
driver_class: MyNamespace\MyDriverImpl
options:
foo: bar
path: %kernel.data_dir%/data.sqlite
memory: true
unix_socket: /tmp/mysql.sock
wrapper_class: MyDoctrineDbalConnectionWrapper
charset: UTF8
logging: %kernel.debug%
platform_service: MyOwnDatabasePlatformService
mapping_types:
enum: string
conn1:
# ...
types:
custom: Acme\HelloBundle\MyCustomType
orm:
auto_generate_proxy_classes: false
proxy_namespace: Proxies
proxy_dir: %kernel.cache_dir%/doctrine/orm/Proxies
default_entity_manager: default # The first defined is used if not set
entity_managers:
default:
# The name of a DBAL connection (the one marked as default is used if not set)
connection: conn1
mappings: # Required
AcmeHelloBundle: ~
class_metadata_factory_name: Doctrine\ORM\Mapping\ClassMetadataFactory
# All cache drivers have to be array, apc, xcache or memcache
metadata_cache_driver: array
query_cache_driver: array
result_cache_driver:
type: memcache
host: localhost
port: 11211
instance_class: Memcache
class: Doctrine\Common\Cache\MemcacheCache
dql:
string_functions:
test_string: Acme\HelloBundle\DQL\StringFunction
numeric_functions:
test_numeric: Acme\HelloBundle\DQL\NumericFunction
datetime_functions:
test_datetime: Acme\HelloBundle\DQL\DatetimeFunction
em2:
# ...
.. code-block:: xml
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
<doctrine:config>
<doctrine:dbal default-connection="default">
<doctrine:connection
name="default"
dbname="database"
host="localhost"
port="1234"
user="user"
password="secret"
driver="pdo_mysql"
driver-class="MyNamespace\MyDriverImpl"
path="%kernel.data_dir%/data.sqlite"
memory="true"
unix-socket="/tmp/mysql.sock"
wrapper-class="MyDoctrineDbalConnectionWrapper"
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
>
<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:dbal>
<doctrine:orm default-entity-manager="default" auto-generate-proxy-classes="false" proxy-namespace="Proxies" proxy-dir="%kernel.cache_dir%/doctrine/orm/Proxies">
<doctrine:entity-manager name="default" query-cache-driver="array" result-cache-driver="array" connection="conn1" class-metadata-factory-name="Doctrine\ORM\Mapping\ClassMetadataFactory">
<doctrine:metadata-cache-driver type="memcache" host="localhost" port="11211" instance-class="Memcache" class="Doctrine\Common\Cache\MemcacheCache" />
<doctrine:mapping name="AcmeHelloBundle" />
<doctrine:dql>
<doctrine:string-function name="test_string>Acme\HelloBundle\DQL\StringFunction</doctrine:string-function>
<doctrine:numeric-function name="test_numeric>Acme\HelloBundle\DQL\NumericFunction</doctrine:numeric-function>
<doctrine:datetime-function name="test_datetime>Acme\HelloBundle\DQL\DatetimeFunction</doctrine:datetime-function>
</doctrine:dql>
</doctrine:entity-manager>
<doctrine:entity-manager name="em2" connection="conn2" metadata-cache-driver="apc">
<doctrine:mapping
name="DoctrineExtensions"
type="xml"
dir="%kernel.root_dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entity"
prefix="DoctrineExtensions\Entity"
alias="DExt"
/>
</doctrine:entity-manager>
</doctrine:orm>
</doctrine:config>
</container>
Configuration Overview
----------------------
This following configuration example shows all the configuration defaults that
the ORM resolves to:
.. code-block:: yaml
doctrine:
orm:
auto_mapping: true
# the standard distribution overrides this to be true in debug, false otherwise
auto_generate_proxy_classes: false
proxy_namespace: Proxies
proxy_dir: %kernel.cache_dir%/doctrine/orm/Proxies
default_entity_manager: default
metadata_cache_driver: array
query_cache_driver: array
result_cache_driver: array
There are lots of other configuration options that you can use to overwrite
certain classes, but those are for very advanced use-cases only.
Caching Drivers
~~~~~~~~~~~~~~~
For the caching drivers you can specify the values "array", "apc", "memcache"
or "xcache".
The following example shows an overview of the caching configurations:
.. code-block:: yaml
doctrine:
orm:
auto_mapping: true
metadata_cache_driver: apc
query_cache_driver: xcache
result_cache_driver:
type: memcache
host: localhost
port: 11211
instance_class: Memcache
Mapping Configuration
~~~~~~~~~~~~~~~~~~~~~
Explicit definition of all the mapped entities is the only necessary
configuration for the ORM and there are several configuration options that 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.
* ``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.root_dir%).
* ``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``.
* ``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.
* ``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.
.. index::
single: Configuration; Doctrine DBAL
single: Doctrine; DBAL configuration
.. _`reference-dbal-configuration`:
Doctrine DBAL Configuration
---------------------------
.. note::
DoctrineBundle supports all parameters that default Doctrine drivers
accept, converted to the XML or YAML naming standards that Symfony
enforces. See the Doctrine `DBAL documentation`_ for more information.
Besides default Doctrine options, there are some Symfony-related ones that you
can configure. The following block shows all possible configuration keys:
.. configuration-block::
.. code-block:: yaml
doctrine:
dbal:
dbname: database
host: localhost
port: 1234
user: user
password: secret
driver: pdo_mysql
driver_class: MyNamespace\MyDriverImpl
options:
foo: bar
path: %kernel.data_dir%/data.sqlite
memory: true
unix_socket: /tmp/mysql.sock
wrapper_class: MyDoctrineDbalConnectionWrapper
charset: UTF8
logging: %kernel.debug%
platform_service: MyOwnDatabasePlatformService
mapping_types:
enum: string
types:
custom: Acme\HelloBundle\MyCustomType
.. code-block:: xml
<!-- xmlns:doctrine="http://symfony.com/schema/dic/doctrine" -->
<!-- xsi:schemaLocation="http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> -->
<doctrine:config>
<doctrine:dbal
name="default"
dbname="database"
host="localhost"
port="1234"
user="user"
password="secret"
driver="pdo_mysql"
driver-class="MyNamespace\MyDriverImpl"
path="%kernel.data_dir%/data.sqlite"
memory="true"
unix-socket="/tmp/mysql.sock"
wrapper-class="MyDoctrineDbalConnectionWrapper"
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
>
<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:dbal>
</doctrine:config>
If you want to configure multiple connections in YAML, put them under the
``connections`` key and give them a unique name:
.. code-block:: yaml
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: Symfony2
user: root
password: null
host: localhost
customer:
dbname: customer
user: root
password: null
host: localhost
The ``database_connection`` service always refers to the *default* connection,
which is the first one defined or the one configured via the
``default_connection`` parameter.
Each connection is also accessible via the ``doctrine.dbal.[name]_connection``
service where ``[name]`` if the name of the connection.
.. _DBAL documentation: http://www.doctrine-project.org/docs/dbal/2.0/en

View File

@@ -0,0 +1,43 @@
Doctrine Bundle
===============
Doctrine DBAL & ORM Bundle for the Symfony Framework.
Because Symfony 2 does not want to force or suggest a specific persistence solutions on the users
this bundle was removed from the core of the Symfony 2 framework. Doctrine2 will still be a major player
in the Symfony world and the bundle is maintained by developers in the Doctrine and Symfony communities.
IMPORTANT: This bundle is developed for Symfony 2.1 and up. For Symfony 2.0 applications the DoctrineBundle
is still shipped with the core Symfony repository.
Installation
------------
1. Old deps and bin/vendors way
Add the following snippets to "deps" files:
.. code-block::
[doctrine-mongodb]
git=http://github.com/doctrine/dbal.git
[doctrine-mongodb-odm]
git=http://github.com/doctrine/doctrine2.git
[DoctrineBundle]
git=http://github.com/doctrine/DoctrineBundle.git
target=/bundles/Doctrine/Bundle/DoctrineBundle
2. Composer
Add the following dependencies to your projects composer.json file:
.. code-block::
"require": {
# ..
"doctrine/doctrine-bundle": ">=2.1"
# ..
}

View File

@@ -0,0 +1,122 @@
{% extends app.request.isXmlHttpRequest ? 'WebProfilerBundle:Profiler:ajax_layout.html.twig' : 'WebProfilerBundle:Profiler:layout.html.twig' %}
{% block toolbar %}
{% set icon %}
<img width="20" height="28" alt="Database" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAcCAYAAABh2p9gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQRJREFUeNpi/P//PwM1ARMDlcGogZQDlpMnT7pxc3NbA9nhQKxOpL5rQLwJiPeBsI6Ozl+YBOOOHTv+AOllQNwtLS39F2owKYZ/gRq8G4i3ggxEToggWzvc3d2Pk+1lNL4fFAs6ODi8JzdS7mMRVyDVoAMHDsANdAPiOCC+jCQvQKqBQB/BDbwBxK5AHA3E/kB8nKJkA8TMQBwLxaBIKQbi70AvTADSBiSadwFXpCikpKQU8PDwkGTaly9fHFigkaKIJid4584dkiMFFI6jkTJII0WVmpHCAixZQEXWYhDeuXMnyLsVlEQKI45qFBQZ8eRECi4DBaAlDqle/8A48ip6gAADANdQY88Uc0oGAAAAAElFTkSuQmCC"/>
<span class="sf-toolbar-status">{{ collector.querycount }}</span>
<span class="sf-toolbar-info-piece-additional-detail">in {{ '%0.2f'|format(collector.time * 1000) }} ms</span>
{% endset %}
{% set text %}
<div class="sf-toolbar-info-piece">
<b>DB Queries</b>
<span>{{ collector.querycount }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Query time</b>
<span>{{ '%0.2f'|format(collector.time * 1000) }} ms</span>
</div>
{% endset %}
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endblock %}
{% block menu %}
<span class="label">
<span class="icon"><img src="{{ asset('bundles/webprofiler/images/profiler/db.png') }}" alt="" /></span>
<strong>Doctrine</strong>
<span class="count">
<span>{{ collector.querycount }}</span>
<span>{{ '%0.0f'|format(collector.time * 1000) }} ms</span>
</span>
</span>
{% endblock %}
{% block panel %}
{% if 'explain' == page %}
{% render 'DoctrineBundle:Profiler:explain' with {
'token': token,
'panel': 'db',
'connectionName': app.request.query.get('connection'),
'query': app.request.query.get('query')
} %}
{% else %}
{{ block('queries') }}
{% endif %}
{% endblock %}
{% block queries %}
<h2>Queries</h2>
{% for connection, queries in collector.queries %}
<h3>Connection <em>{{ connection }}</em></h3>
{% if queries is empty %}
<p>
<em>No queries.</em>
</p>
{% else %}
<ul class="alt">
{% for i, query in queries %}
<li class="{{ cycle(['odd', 'even'], i) }}">
<div>
{% if query.explainable %}
<a href="{{ path('_profiler', {'panel': 'db', 'token': token, 'page': 'explain', 'connection': connection, 'query': i}) }}" onclick="return explain(this);" style="text-decoration: none;" title="Explains" data-target-id="explain-{{ i }}-{{ loop.parent.loop.index }}" >
<img alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="display: inline;" />
<img alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="display: none;" />
</a>
{% endif %}
<code>{{ query.sql }}</code>
</div>
<small>
<strong>Parameters</strong>: {{ query.params|yaml_encode }}<br />
<strong>Time</strong>: {{ '%0.2f'|format(query.executionMS * 1000) }} ms
</small>
{% if query.explainable %}
<div id="explain-{{ i }}-{{ loop.parent.loop.index }}" class="loading"></div>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<h2>Database Connections</h2>
{% if collector.connections %}
{% include 'WebProfilerBundle:Profiler:table.html.twig' with {data: collector.connections} only %}
{% else %}
<p>
<em>No connections.</em>
</p>
{% endif %}
<h2>Entity Managers</h2>
{% if collector.managers %}
{% include 'WebProfilerBundle:Profiler:table.html.twig' with {data: collector.managers} only %}
{% else %}
<p>
<em>No entity managers.</em>
</p>
{% endif %}
<script type="text/javascript">//<![CDATA[
function explain(link) {
"use strict";
var imgs = link.children,
target = link.getAttribute('data-target-id');
Sfjs.toggle(target, imgs[0], imgs[1])
.load(
target,
link.href,
null,
function(xhr, el) {
el.innerHTML = 'An error occurred while loading the details';
Sfjs.removeClass(el, 'loading');
}
);
return false;
}
//]]></script>
{% endblock %}

View File

@@ -0,0 +1,20 @@
<small><strong>Explanation</strong>:</small>
<table style="margin: 5px 0;">
<thead>
<tr>
{% for label in data[0]|keys %}
<th>{{ label }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in data %}
<tr>
{% for item in row %}
<td>{{ item }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>