How to install a Symfony 2.0 Bundle from Zip file

限于喜欢 提交于 2019-12-25 02:41:05

问题


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.


回答1:


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

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




回答2:


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!




回答3:


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(),


来源:https://stackoverflow.com/questions/8805231/how-to-install-a-symfony-2-0-bundle-from-zip-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!