How to save doctrine database schema in a Symfony controller? -
i'm using symfony 2.3 , doctrine 2 , need user save schema of doctrine database file (*.sql). need action method , send file user
just started, should work in concept. didn't run it, assume might need little tweaks side.
<?php use symfony\component\console\input\arrayinput; use symfony\component\console\output\nulloutput; use doctrine\bundle\doctrinebundle\command\proxy\createschemadoctrinecommand; // controller public function myaction() { $command = new createschemadoctrinecommand(); $command->setcontainer($this->container); $input = new arrayinput(array('--dump-sql' => true)); $output = new nulloutput(); $schema = $command->run($input, $output); //this schema // write file if want file_put_contents('path/to/schema.sql', $schema); }
references:
- similar question
- php file_put_contents()
- symfony2 filesystem
Comments
Post a Comment