【问题标题】:how and where to add DoctrineFixturesBundle manually in symfony 2.6?在 symfony 2.6 中如何以及在何处手动添加 DoctrineFixturesBundle?
【发布时间】:2017-04-24 13:49:47
【问题描述】:

我正在尝试在我的项目中使用 DoctrineFixturesBundle,该项目使用DoctrineFixturesBundle 将一些测试数据加载到数据库中。我从 github 下载了它,但不知道在哪里添加它以及如何让它自动加载。

根据它说使用 Composer 的文档。但它不适用于我公司的网络代理。

第二件事是 - 如何理解appkernal.php 中给出的捆绑包路径。如果我将DoctrineFixturesBundle 放在vendor 文件夹下,我应该如何在appkernal.php 中提及它

$bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),

请帮忙。

【问题讨论】:

  • 你的项目有 composer.json 文件吗?
  • 没有。没有composer.json,但我也试过了。我创建了一个 composer.json 文件并安装/更新它。完全作曲家在代理后面不起作用。所以我需要手动设置这个包。
  • 至少我需要知道 twig bundle 是如何设置的。它位于供应商文件夹中。然后在 appkernal 中为其添加的路径是 - Symfony\Bundle\TwigBundle\TwigBundle()。怎么读?。请解释一下。

标签: php symfony bundle


【解决方案1】:

你错过了很多,因为没有使用作曲家。您应该尝试联系您的网络管理员并弄清楚如何使其工作。

还有few methods,您可以尝试让作曲家在代理中工作。

但如果你不能真正让作曲家工作, 尝试实例化DoctrineFixturesBundle

new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle()

app/AppKernel.php文件中registerBundles()方法的$bundles数组中。

$bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),
        new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

清除缓存并检查doctrine:fixtures:load是否存在。

如果它不起作用,您应该弄清楚Autoloading 在您的项目中是如何设置的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    • 2019-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-09
    相关资源
    最近更新 更多