How to access the Sqls of the updates made by Doctrine Orm:schema?

Asked

Viewed 54 times

1

I have an application running on a server (production) that does not give access to ../vendor/bin/doctrine and so I can’t run the commands, like the orm:schema-tool:update, for example. I am running commands in my development environment, usually.

How do I access the commands executed by orm:schema so that I can run them correctly in my production environment, simulating the action of the ORM itself and keeping the banks properly paired?

1 answer

0


Instead of accessing the executable commands ../vendor/bin/doctrine, you can create a web-accessible script (of course, with some necessary authentication) to do what you need.

Behold this section in the Doctrine documentation.

Briefly, it is enough to instantiate the SchemaTool passing his EntityManager as argument, and call the method updateSchema passing the classes of its application as argument:

<?php

$tool = new \Doctrine\ORM\Tools\SchemaTool($em);

$classes = array(
  $em->getClassMetadata('Entities\User'),
  $em->getClassMetadata('Entities\Profile')
);

$tool->updateSchema($classes);
  • Grateful @Rodrigo Rigotti

Browser other questions tagged

You are not signed in. Login or sign up in order to post.