Skip to content

Commit 810002c

Browse files
committedOct 10, 2024·
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 810002c

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
9+
profiling_collect_backtrace: '%kernel.debug%'
10+
use_savepoints: true
11+
orm:
12+
auto_generate_proxy_classes: true
13+
enable_lazy_ghost_objects: true
14+
report_fields_where_declared: true
15+
validate_xml_mapping: true
16+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
17+
identity_generation_preferences:
18+
Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
19+
auto_mapping: true
20+
mappings:
21+
App:
22+
type: attribute
23+
is_bundle: false
24+
dir: '%kernel.project_dir%/src/Entity'
25+
prefix: 'App\Entity'
26+
alias: App
27+
controller_resolver:
28+
auto_mapping: false
29+
30+
when@test:
31+
doctrine:
32+
dbal:
33+
# "TEST_TOKEN" is typically set by ParaTest
34+
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
35+
36+
when@prod:
37+
doctrine:
38+
orm:
39+
auto_generate_proxy_classes: false
40+
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
41+
query_cache_driver:
42+
type: pool
43+
pool: doctrine.system_cache_pool
44+
result_cache_driver:
45+
type: pool
46+
pool: doctrine.result_cache_pool
47+
48+
framework:
49+
cache:
50+
pools:
51+
doctrine.result_cache_pool:
52+
adapter: cache.app
53+
doctrine.system_cache_pool:
54+
adapter: cache.system
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
" healthcheck:",
32+
" test: [\"CMD\", \"pg_isready\", \"-d\", \"${POSTGRES_DB:-app}\", \"-U\", \"${POSTGRES_USER:-app}\"]",
33+
" timeout: 5s",
34+
" retries: 5",
35+
" start_period: 60s",
36+
" volumes:",
37+
" - database_data:/var/lib/postgresql/data:rw",
38+
" # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!",
39+
" # - ./docker/db/data:/var/lib/postgresql/data:rw"
40+
],
41+
"volumes": ["database_data:"]
42+
},
43+
"docker-compose.override.yml": {
44+
"services": [
45+
"database:",
46+
" ports:",
47+
" - \"5432\""
48+
]
49+
}
50+
},
51+
"conflict": {
52+
"symfony/framework-bundle": "<7.1"
53+
}
54+
}
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)