-1

i have project having two folder one is symfony and another is my project i extend symfony to project folder and set mappings from project folder what i need i need multiple mappings for doctrine orm

my requirememt is i have a class (not a entity) SuperClass for same properties which i extends to Entity files so i need to define class in mappings as well

i doctrine they said mappings:

                # An array of mappings, which may be a bundle name or something else
                mapping_name:
                    mapping:              true
                    type:                 ~
                    dir:                  ~
                    alias:                ~
                    prefix:               ~
                    is_bundle:            ~

how to define multiple i did but not working

orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    mappings:
# not working one time only one mapping working i need to both will work
      Project\Component\User:
        is_bundle: false
        type: xml
        dir: '%kernel.project_dir%/config/orm-mappings/doctrine'
        prefix: 'Project\Component\User'
        alias: Project\Component\User
        mapping: true
# this is working
      Project/User:
        is_bundle: false
        type: xml
        dir: '%kernel.project_dir%/config/orm-mappings/doctrine'
        prefix: 'Project/User'
        alias: Project/User
        mapping: true

My SuperClass mappings not working only. if i move my file to in this Project/User then they bind properly and working but i need file put separate

2
  • 1
    You are using "\" and "/" in each config. Maybe that?
    – pabgaran
    Commented Jun 6, 2019 at 6:55
  • improve formatting Commented Jun 6, 2019 at 8:13

1 Answer 1

0

Worked i have create one more folder for mapping SuperClass so now i have two dir and two different namespace as well

mappings:

  Project\Component\User:
    is_bundle: false
    type: xml
    dir: '%kernel.project_dir%/config/orm-mappings/mapping-superclass'
    prefix: 'Project\Component\User'
    alias: Project\Component\User
    mapping: true

  Project\User:
    is_bundle: false
    type: xml
    dir: '%kernel.project_dir%/config/orm-mappings/doctrine'
    prefix: 'Project\User'
    alias: Project\User
    mapping: true

this will work for you one namespace for db mapping which is Project\User and SuperClass namespace is Project\Component\User

1
  • For people reading this in a rush and trying to figure out the difference: Note that the problem was that both mappings were pointing to the same dir (see the dir config). Change that and you will fix the problem.
    – Cesc
    Commented Nov 24, 2021 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.