Skip to content

Instantly share code, notes, and snippets.

@botris
Created September 18, 2020 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save botris/f21177dc4f0dd9191966524ad3c85263 to your computer and use it in GitHub Desktop.
Save botris/f21177dc4f0dd9191966524ad3c85263 to your computer and use it in GitHub Desktop.
Drupal/legacy table to Symfony Doctrine entity
DATABASE_URL=mysql://db:db@localhost/db?sslmode=disable&charset=utf8mb4&serverVersion=5.7
DATABASE_DRUPAL_URL=mysql://db:db@localhost/legacy?sslmode=disable&charset=utf8mb4&serverVersion=5.7
# config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
drupal:
url: '%env(resolve:DATABASE_DRUPAL_URL)%'
schema_filter: /^(table_name)$/
orm:
auto_generate_proxy_classes: true
default_entity_manager: default
entity_managers:
default:
auto_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
connection: default
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
drupal:
connection: drupal
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Drupal'
prefix: 'App\Entity\Drupal'
alias: App
@botris
Copy link
Author

botris commented Sep 18, 2020

Create folder "src/Entity/Drupal".
Run php bin/console doctrine:mapping:import "App\\Entity\\Drupal" annotation --em=drupal --path=src/Entity/Drupal --force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment