Skip to content
Advertisement

Symfony 4 make:entity {entity} generate in a custom directory in a multi doctrine connection

New to symfony here

I have a two connection setup in my config/packages/doctrine.yaml.

Connection 1 is default; //connects to localhost:mysql:root:password:local_db
Connection 2 is remote; // connection to a server xxx.xxx.xx.xxx.:username:pwd:remote_db

Is it possible to generate an Entity class using the cli tool php bin/console make:entity Product to generate entity in a custom directory.

When I run the above command the “Product” enttity class gets generated in my src/Entity/ directory but I want it to be generated according to our needs,

so lets say in scenario 1 I want it to generate the Entity class in src/Entity/Customer/ directory and

in scenario 2 I want it to generate the Entity class in src/Entity/Products/ directory. If I am able to do this then, the migrations and entity mappings becomes a lot easier for me.

Advertisement

Answer

This works: bin/console make:entity Customer\Cart:

created: src/Entity/Customer/Cart.php
created: src/Repository/Customer/CartRepository.php
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement