First, configure the ORM mappings in doctrine.yaml in.
as follows
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7.24'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
Then generate the mapping relationship, which is generated ORM
php bin/console doctrine:mapping:import "App\Entity" xml --path=config/doctrine
Generating entity classes
php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity
Get set generation method
php bin/console make:entity --regenerate App
Reference: https://symfony.com/doc/current/doctrine/reverse_engineering.html