diff --git a/src/DatabaseExtension.php b/src/DatabaseExtension.php index 50e586a..1a7ad24 100644 --- a/src/DatabaseExtension.php +++ b/src/DatabaseExtension.php @@ -37,6 +37,9 @@ public function afterCompile(ClassType $class): void . '$entityManager->getConfiguration()->addCustomNumericFunction(\'rand\', ' . Rand::class . '::class);' . "\n" . '$entityManager->buildCache();' . "\n" . $initialize->getBody() + . (PHP_SAPI === 'cli' ? "\n" + . OrmSchemaUpdateTool::class . '::setContainer($this);' . "\n" + . 'register_shutdown_function([' . OrmSchemaUpdateTool::class . '::class, \'run\']);' : '') ); } diff --git a/src/OrmSchemaUpdateTool.php b/src/OrmSchemaUpdateTool.php new file mode 100644 index 0000000..e0e7ec0 --- /dev/null +++ b/src/OrmSchemaUpdateTool.php @@ -0,0 +1,50 @@ +getByType(Application::class); + + exit($application->run()); + } catch (\Throwable $e) { + Debugger::log($e); + + echo $e->getMessage(); + + exit($e->getCode() ? : 1); + } + } + } + + /** + * @param Container $container + */ + public static function setContainer(Container $container): void + { + self::$container = $container; + } + +} \ No newline at end of file