本文介绍了Doctrine 2 CLI中的CLI命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯所有的我正在编写一个程序来转换数据库中的一些数据,然后调用Doctrine从Mysql数据库结构构建YAML文件。我在PHP中工作的学说。但是我不知道如何从PHP中调用CLI命令。以下是Doctrine 2 CLI命令,可以执行所需的操作。



php ./doctrine orm:convert-mapping --filter =users--from-database yml ./test



这个命令可以从Linux命令行中工作,但是如何通过Doctrine对象来做同样的事情?我不想使用PHP exec语句将命令发送到shell。我想使用Doctrine对象模型。

解决方案

Don!:



 $ cmd_string =php ./doctrine orm:generate-entities --generate-annotations = 1 --regenerate-entities = 1 $ this-> entity_file_dir; 
$ result = array();
exec($ cmd_string,&$ $ result);



希望这有帮助,
-Don!


Hey all. I am writing a program that will transform some data in our database, and then call Doctrine to build YAML files from said Mysql Database structure. I have Doctrine working from within PHP. However I can't figure out how to call the CLI commands from within PHP. Following is the Doctrine 2 CLI command that does what I need.

php ./doctrine orm:convert-mapping --filter="users" --from-database yml ./test

This command works from the Linux command line, but how to I do this same thing via Doctrine objects? I don't want to just use the PHP exec statement to send a command to the shell. I wish to use the Doctrine object model.

解决方案

Don!:

Apparently this is not a very common programming method. However, I have used Doctrine from PHP by calling it via the PHP EXEC command. I know you said that you would not like to do it this way. However, it actually works quite well. Below is an example of such a solution.

$cmd_string = "php ./doctrine orm:generate-entities --generate-annotations=1 --regenerate-entities=1 $this->entity_file_dir";
$result = array();
exec($cmd_string, &$result);

Hope this helps, -Don!

这篇关于Doctrine 2 CLI中的CLI命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 20:10