如何从 Zip 文件安装 Symfony 2.0 捆绑包

发布于 2024-12-25 16:53:48 字数 987 浏览 0 评论 0原文

我尝试按照 http://symfony.com/doc/2.0 中所述安装 FixturesBundle /bundles/DoctrineFixturesBundle/index.html 但我的代理不会让我出去。

所以我去了 https://github.com/doctrine/data-fixtures 并下载了一个 zip从最新的提交开始。

我解压到供应商目录并将其重命名为doctrine-fixures。我按照教程中的说明编辑了 autoload.php 和 AppKernel.php 文件。

当我运行:

php app\console doctrine:fixtures:load

我收到以下消息:

PHP Fatal error:  Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesB
undle' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on
line 20

Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle
' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on line
20

有没有办法运行将其指向 zip 文件的捆绑包安装?

我在 Windows 7 上运行 Symfony 2.0.9。

I tried installing the FixturesBundle as described in http://symfony.com/doc/2.0/bundles/DoctrineFixturesBundle/index.html but my proxy wont let me out.

So I went to https://github.com/doctrine/data-fixtures and download a zip from the latest commit.

I unzipped into the vendor directory and renamed it to doctrine-fixures. I edited the autoload.php and AppKernel.php files as described in the tutorial.

When I run:

php app\console doctrine:fixtures:load

I get the following message:

PHP Fatal error:  Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesB
undle' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on
line 20

Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle
' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on line
20

Is there a way to run the installation of bundle pointing it to a zip file?

I´m running Symfony 2.0.9 on Windows 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倒带 2025-01-01 16:53:48

似乎 Doctrine 包已从 Symfony 范围移回 Doctrine。

请使用 https://github.com/doctrine/DoctrineFixturesBundle

Seems like the doctrine bundle has been moved outside of Symfony scope back to Doctrine.

Please, use https://github.com/doctrine/DoctrineFixturesBundle

寂寞美少年 2025-01-01 16:53:48

我遇到了同样的问题,这就是我成功解决它的方法。我开始下载此文件 data-fixturesDoctrineFixturesBundle,将两者解压到 /vendor/doctrine并创建了这个文件夹结构:

vendor
  - doctrine
    - doctrine-fixtures-bundle
      - Doctrine
        - Bundle
         - FixturesBundle
           DoctrineFixturesBundle.php
           ..other files...


vendor
  - doctrine
    - data-fixtures
      - lib
      - test
      composer.json
      ..other files...

然后我编辑了 AppKernel.php 并添加了

public function registerBundles(){
  .....
  new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
  .....
}

编辑位于项目根目录中的 composer.json 并添加了这两行:

"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"

我的,现在如下所示:

{
    "autoload": {
        "psr-0": { 
            "": "src/",
            "Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
            "Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
        }
    }
}

然后执行 composer dump-autoload -o 来重新创建类映射。这一切都归功于用户 Wouter Jnifr 回答了我的问题如何离线安装 DoctrineFixturesBundle

快乐编码!

I had the same problem and this is how i successfully solved it. I started to download this files data-fixtures and DoctrineFixturesBundle, unzipped both into /vendor/doctrine and created this folder structure:

vendor
  - doctrine
    - doctrine-fixtures-bundle
      - Doctrine
        - Bundle
         - FixturesBundle
           DoctrineFixturesBundle.php
           ..other files...


vendor
  - doctrine
    - data-fixtures
      - lib
      - test
      composer.json
      ..other files...

Then i edited the AppKernel.php and added

public function registerBundles(){
  .....
  new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
  .....
}

Edited the composer.json located in the root of the project and added this 2 lines:

"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"

Mine, now look like this:

{
    "autoload": {
        "psr-0": { 
            "": "src/",
            "Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
            "Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
        }
    }
}

afterwards execute composer dump-autoload -o to recreate the classmap. All this was thanks to the users Wouter J and nifr that answered my question How to install DoctrineFixturesBundle offline

Happy coding!

夜还是长夜 2025-01-01 16:53:48

是的,Doctrine 确实正在从 Symfony 命名空间中移出(请参阅此处)。

因此,如果您使用从网站下载的 Symfony 标准发行版(不使用 git),并且想要手动安装 FixturesBundle,则必须从 此处,将 zip 解压到

YourProject/vendor/doctrine-fixtures

Download the FixturesBundle from 此处,然后将其提取到

YourProject/vendor/bundles/Doctrine/Bundle/FixturesBundle

然后您必须注册库的命名空间,通过添加

'Doctrine\\\\Common\\\\DataFixtures' => \__DIR\__.'/../vendor/doctrine-fixtures/lib',

autoload 来完成.php

此外,您还必须注册 Doctrine 的命名空间,因为应用程序的某些部分将使用从 Symfony 命名空间提供的 DoctrineBundle,但新下载的 FixturesBundle 将使用新 Doctrine 的命名空间,因此要使其正常工作,请在 autoload.php 中添加以下行(注意在 Doctrine 之前执行此操作)命名空间,请记住更具体的规则先行!)

'Doctrine\\\\Bundle' => \__DIR\__.'/../vendor/bundles',

因此您现在要做的就是在您的 AppKernel.php 编写中注册新包

new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

Yes, it's true that Doctrine is being moved away from the Symfony namespace (see here).

So if you're using the Symfony standard distribution you download from the website (without using git), and you want to have the FixturesBundle installed manually, you have to download the doctrine-fixtures library from here, extract the zip into

YourProject/vendor/doctrine-fixtures

Download the FixturesBundle from here, and extract it in

YourProject/vendor/bundles/Doctrine/Bundle/FixturesBundle

Then you have to register the library's namespace, do it by adding

'Doctrine\\\\Common\\\\DataFixtures' => \__DIR\__.'/../vendor/doctrine-fixtures/lib',

in your autoload.php.

In addition, you'll have to register the Doctrine's namespace, because some part of your application will be using the DoctrineBundle shipped from the Symfony namespace, but the new downloaded FixturesBundle will be using the new Doctrine's namespace, so to make it work, in your autoload.php add the following line (taking care you do it before the Doctrine namespace, remember that more specific rules go first!)

'Doctrine\\\\Bundle' => \__DIR\__.'/../vendor/bundles',

So all you have to do now is to register the new bundle in your AppKernel.php writing

new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文