English 中文(简体)
Symfony2, 如何装入 -- fixtures 选项的固定装置?
原标题:Symfony2, How to load fixtures with --fixtures option?
  • 时间:2012-05-23 20:00:06
  •  标签:
  • symfony

我需要一个在Symfony2下面命令的例子:

php app/console doctrine:mongodb:fixtures:load --fixtures=/path/to/fixture 

我不知道如何设置 < code> - fixtures=/ path/ to/ fixture 。 我可以全部加载, 但我不能只为一个新固定而这样做!

/path/to/fixture应该是什么格式?

我还尝试了这个 -fixtures=src/PMI/ UserBundle/DataFixtures/ORM/FetureFixtures ,但我每次都得到这个:

 [InvalidArgumentException]                             
  Could not find any fixtures to load in:                               
  - src/PMI/UserBundle/DataFixtures/ORM/FeatureFixtures
最佳回答

我知道这是古老的,但其他人已经问过,这些答案可能没有包括其他一些问题。

您只需要指定文件夹, 而不是文件。 在上述问题中, 它不清楚 FetureFixtures 是 php 文件, 还是实际上是一个文件夹。 如果它只是一个 php 文件而不是一个文件夹, 它可能会失败 。 这是在假设 Fixtures 是 php 文件 的情况下装入定着 的正确方式 :

doctrine:fixtures:load --fixtures=src/PMI/UserBundle/DataFixtures/ORM --append
问题回答

您可以用真实路径定义一个固定点 。

php app/console doctrine:fixtures:load --fixtures=src/MyBundle/DataFixtures/ORM/LoadMyFixturesData.php

它不要求, 但如果您想要手动指定要装入定着类的目录, 您可以使用此目录 :

例如,如果我在目录符号中执行命令

--fixtures=/src/yourBundle/fixture 

启动时要使用 doctrine: fixtures:load -- group=FetureFixtures

对于 ylmfony +3, 您可以使用此命令 :

php bin/conole 理论:fixtures:load -- group= yourFixtures -- 附录

或短版本 :

php bin/conole d:f:l -- group= yourFixtures -- 附录


其中选项:

  • --group Target fixture. If you do not use the option, then load all your fixtures;
  • --append Without this option the load fixture command will remove all data from your database. Use this option to add new data without removing old data.




相关问题
Symfony 5, I can t start the server

I develop a symfony project and everything was fine. But since yesterday I can not launch the server: enter image description here The commands symfony server:start and symfony server:stop don t work ...

learning symfony 1.4 will be good when using symfony 2.0?

I know that the architecture is different in symfony 2.0 but im learning 1.4 right now. I wonder if this knowledge i gain about 1.4 will be usable for 2.0 in some extent or will it be a total waste ...

Is symfony 2.0 stable enough to use? [closed]

I wonder if Symfony 2.0 is stable enough to use? Because I ve never used Symfony before. It seems that Symfony 2 is much better than the previous version and I don t want to relearn/recode ...

your experience using symfony 2.0 [closed]

I m going to start a new project that s building web apps from scratch. I have been thinking about using symfony framework for this project. Should I start using symfony 2.0 or stick with 1.4 ? I ...

How to increase the session timeout in Symfony

I would like to know how to increase the session timeout in symfony. Is it enough to only adjust the symfony configuration settings or must I also configure anything in my php.ini file?

How stable or unstable is symfony 2.0? [closed]

Well, I know it s a preview, and I know it says that it s not yet ready for production, and yet I dare ask the question. I need to start building a pretty big application, which is planned to go live ...

热门标签