Symfony-Bundle
Symfony-Bundle copied to clipboard
Add an example of database connection only for the bundle
I needed to separate the cron bundle database from the default database of my symfony project. As I didn't find any example of doing such config, i spent hours trying. Now it works and it's quite easy but if you could share an example it could be helpful! My example : `
/config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
crondb:
driver: 'pdo_pgsql'
url: '%env(resolve:CRON_DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
default_entity_manager: default
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
connection: default
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
cron:
connection: crondb
mappings:
CronCronBundle:
type: annotation
dir: '%kernel.project_dir%/vendor/cron/cron-bundle/Entity'
prefix: 'Cron\CronBundle\Entity'
alias: Cron`