I have one product for many customers but I want to have one code base. Every customer needs some specific changes in database(entities repos) and in his own themes. Every customer has his own database. I need to find a solution to define in configuration for every customer witch entities must be read to create or update his own database schema.
In my bundles i have this structure in Entities
Acme\JobBundle\Entities\Customer.php
Acme\JobBundle\Entities\Customer1\Customer.php
Acme\JobBundle\Entities\Customer2\Customer.php
Acme\JobBundle\Entities\Customer3\Customer.php
Acme\JobBundle\Entities\Customer.php is an abstract class
Acme\JobBundle\Entities\Customer1\Customer.php extends Acme\JobBundle\Entities\Customer.php
Thank you for your time
Accordingly to the Symfony2 doc :
You can define multi entity managers and the associated mapping:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
customer:
driver: "%database_driver2%"
host: "%database_host2%"
port: "%database_port2%"
dbname: "%database_name2%"
user: "%database_user2%"
password: "%database_password2%"
charset: UTF8
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
AppBundle: ~
AcmeStoreBundle: ~
customer:
connection: customer
mappings:
AcmeCustomerBundle: ~
And of course you can create your schema like this:
# Play only with "default" mappings
$ php app/console doctrine:schema:update --force
# Play only with "customer" mappings
$ php app/console doctrine:schema:update --force --em=customer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.