Is there a way to create and modify entities and tables in a db dynamically (from a php script)?
For example, I want to generate an entity from an array:
fields{
id: integer,
name: string,
... and so on
}
And than generate a table in the bd
I know only one simple solution: to create yml or xml file and run a console command from my script, or use DBAL
You can also generate an entity from command line, for example:
This uses the SensioGeneratorBundle, that is defined only in
dev
andtest
environments.So, it is a little bit hacky but you'll need to call this command with the right environment:
The Process component can be used in order to launch this command.
So you may end up with something like this: