1

I am currently developing an backup system which is backuping database dump and media files.

I know that php app/console doctrine:schema:create --dump-sql will create database dump for me, but thats not what i need. I need to create database dump file exactly from php class so i can work with it (for example, to encode it).

How can i create database dump from class using symfony?

2
  • You want to get just empty schema of your database? This same what's created by command? Commented Feb 24, 2016 at 20:43
  • $dump = shell_exec('php app/console etc...');? Commented Feb 24, 2016 at 20:46

1 Answer 1

3

Just use schema tool manually (example can be used in controller action):

$em = $this->get('doctrine')->getManager();
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$sqls = $schemaTool->getCreateSchemaSql($metadatas);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.