in my Symfony 5 application I have an architecture like this:
src/
├─ Website/
│ ├─ Entity/
│ ├─ Repository/
│ ├─ Controller/
├─ Application/
│ ├─ Entity/
│ ├─ Repository/
│ ├─ Controller/
When I create an entity with the command php bin/console make:entity, I would like to be able to specify on which folder to create the entity, and that it also creates the repository on the correct folder automatically.
Here is my configuration of the doctrine.yaml file
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App\Application:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Application/Entity'
prefix: 'App\Application\Entity'
alias: Application
App\Website:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Website/Entity'
prefix: 'App\Website\Entity'
alias: Website
For the moment, the only solution I have found is the following:

php bin/console make:entitysrc/Application/Entity folder : \App\Application\Entity\Totoosrc/Application/Entity/Totoo.phpsrc/Repository/Application\Entity\TotooRepository.phpHow could we optimize this way of creating entities with the command, in order to automatically create the entity and the repository in the right place, and if possible without having to type the full path each time? (Maybe thanks to the aliases in my doctrine setup? But I don't see how)
To perform this do you need to add a maker.yaml file
with the following lines (e.g)
# config/package/dev
maker:
root_namespace: 'App\Application\'
When you will type : bin/console make:entity the new entity or modifying an existing Entity will check it out into this folder.
P:S watch out in which env do you configure it, dev in my case
That's it ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With