Skip to content

Commit 72a06c6

Browse files
committed
Add a recipe for DoctrineBundle 2.13
This recipe avoids getting deprecations from the ORM by turning on new settings. For the identity generation precedence, using `identity` is the best choice for new projects (especially when using DBAL 4.x from the start).
1 parent 74769e1 commit 72a06c6

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
doctrine:
2+
dbal:
3+
url: '%env(resolve:DATABASE_URL)%'
4+
5+
# IMPORTANT: You MUST configure your server version,
6+
# either here or in the DATABASE_URL env var (see .env file)
7+
#server_version: '16'
8+
use_savepoints: true
9+
orm:
10+
auto_generate_proxy_classes: true
11+
enable_lazy_ghost_objects: true
12+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
13+
auto_mapping: true
14+
report_fields_where_declared: true
15+
identity_generation_preferences:
16+
Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
17+
mappings:
18+
App:
19+
is_bundle: false
20+
dir: '%kernel.project_dir%/src/Entity'
21+
prefix: 'App\Entity'
22+
alias: App
23+
24+
when@test:
25+
doctrine:
26+
dbal:
27+
# "TEST_TOKEN" is typically set by ParaTest
28+
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
29+
30+
when@prod:
31+
doctrine:
32+
orm:
33+
auto_generate_proxy_classes: false
34+
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
35+
query_cache_driver:
36+
type: pool
37+
pool: doctrine.system_cache_pool
38+
result_cache_driver:
39+
type: pool
40+
pool: doctrine.result_cache_pool
41+
42+
framework:
43+
cache:
44+
pools:
45+
doctrine.result_cache_pool:
46+
adapter: cache.app
47+
doctrine.system_cache_pool:
48+
adapter: cache.system
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"bundles": {
3+
"Doctrine\\Bundle\\DoctrineBundle\\DoctrineBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"config/": "%CONFIG_DIR%/",
7+
"src/": "%SRC_DIR%/"
8+
},
9+
"env": {
10+
"#1": "Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url",
11+
"#2": "IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml",
12+
"#3": "",
13+
"#4": "DATABASE_URL=\"sqlite:///%kernel.project_dir%/var/data.db\"",
14+
"#5": "DATABASE_URL=\"mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4\"",
15+
"#6": "DATABASE_URL=\"mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4\"",
16+
"DATABASE_URL": "postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
17+
},
18+
"dockerfile": [
19+
"RUN install-php-extensions pdo_pgsql"
20+
],
21+
"docker-compose": {
22+
"docker-compose.yml": {
23+
"services": [
24+
"database:",
25+
" image: postgres:${POSTGRES_VERSION:-16}-alpine",
26+
" environment:",
27+
" POSTGRES_DB: ${POSTGRES_DB:-app}",
28+
" # You should definitely change the password in production",
29+
" POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}",
30+
" POSTGRES_USER: ${POSTGRES_USER:-app}",
31+
" volumes:",
32+
" - database_data:/var/lib/postgresql/data:rw",
33+
" # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!",
34+
" # - ./docker/db/data:/var/lib/postgresql/data:rw"
35+
],
36+
"volumes": ["database_data:"]
37+
},
38+
"docker-compose.override.yml": {
39+
"services": [
40+
"database:",
41+
" ports:",
42+
" - \"5432\""
43+
]
44+
}
45+
},
46+
"conflict": {
47+
"doctrine/orm": "<2.14",
48+
"symfony/dependency-injection": "<6.2",
49+
"symfony/framework-bundle": "<5.3"
50+
}
51+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Modify your DATABASE_URL config in <fg=green>.env</>
2+
3+
* Configure the <fg=green>driver</> (postgresql) and
4+
<fg=green>server_version</> (16) in <fg=green>config/packages/doctrine.yaml</>

doctrine/doctrine-bundle/2.13/src/Entity/.gitignore

Whitespace-only changes.

doctrine/doctrine-bundle/2.13/src/Repository/.gitignore

Whitespace-only changes.

0 commit comments

Comments
 (0)