doctrine/doctrine-bundle
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/cache | 2.2.0 | 15.99 kB | MIT | prod | |
doctrine/dbal | 4.0.2 | - | MIT | prod dev | |
doctrine/deprecations | 1.1.3 | 7.42 kB | MIT | prod dev | |
doctrine/persistence | 3.3.2 | - | MIT | prod dev | |
doctrine/sql-formatter | 1.2.0 | - | MIT | prod | |
psr/log | 3.0.0 | 6.77 kB | MIT | prod dev | |
symfony/cache | v7.0.7 | - | MIT | prod dev | |
symfony/config | v7.0.7 | - | MIT | prod dev | |
symfony/console | v7.0.7 | - | MIT | prod dev | |
symfony/dependency-injection | v7.0.7 | - | MIT | prod dev | |
symfony/deprecation-contracts | v3.4.0 | 3.27 kB | MIT | prod dev | |
symfony/doctrine-bridge | v7.0.7 | - | MIT | prod | |
symfony/framework-bundle | v7.0.7 | - | MIT | prod | |
symfony/polyfill-php80 | v1.29.0 | - | MIT | prod dev | |
symfony/service-contracts | v3.4.2 | - | MIT | prod dev | |
symfony/string | v7.0.7 | - | MIT | prod dev | |
symfony/var-exporter | v7.0.7 | - | MIT | prod dev |
Doctrine Bundle is an integral component for the Symfony Framework and is developed under the Doctrine Project. It primarily provides persistence services and related functionalities. This is executed with the help of its Object Relational Mapper (ORM) and the robust Database Abstraction Layer (DBAL) which forms its foundation. The Doctrine ORM grants developers an option to script database queries using their proprietary object-oriented SQL dialect called Doctrine Query Language (DQL). This grants them an efficient alternative to SQL and lets them maintain flexibility without necessitating excessive code duplication. Meanwhile, DBAL offers an array of features for database schema introspection, schema management, and PDO abstraction.
To use Doctrine Bundle in your Symfony project, you must first install it using the Composer dependency manager. Here is a command to install Doctrine Bundle:
composer require doctrine/doctrine-bundle
Once Doctrine Bundle is installed, it can be used to configure database connections and use the console for RDBMS administration. Here is an example of basic setup in Symfony:
//.env
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
//config/packages/doctrine.yaml
doctrine:
dbal:
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
With this setup, you can then create entity repositories with Doctrine:
//src/Repository/UserRepository.php
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class UserRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
//...
}
This example demonstrates how to configure the Doctrine Bundle, define the ORM mappings and create entity repositories.
The official documentation for Doctrine Bundle is rendered and readily accessible on the Symfony website at this URL. The source of the documentation is available in the Resources/docs folder in the repository. The documentation provides in-depth details on how to configure and use the Doctrine Bundle. Additionally, it also serves as an extensive reference guide to the Doctrine Query Language (DQL) and DBAL functionalities.