symfony2.1捆绑版本混乱,用于symfony和sonata admin / knp菜单捆绑 [英] symfony2.1 bundle version confusion, for symfony and sonata admin / knp menu bundle

查看:434
本文介绍了symfony2.1捆绑版本混乱,用于symfony和sonata admin / knp菜单捆绑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对一个新项目使用symfony2.1。我尝试安装symfony2与作曲家。
但是有多个错误/问题,所以我还为粗体字体样式中的每个问题也有问题。
有时我不知道我是否以正确的方式。

I want to use symfony2.1 for a new project. I try to install symfony2 with composer. But there were multiple errors/problems and so I have also questions for each problem in bold font style. Sometimes I don't know if I do it the right way.

我想使用一个稳定的版本,所以我选择了2.1.0版本,而不是dev / master。

I want to use a stable version so I chosen the 2.1.0 version and not the dev/master.

php composer.phar create-project symfony/framework-standard-edition symfony v2.1.0

结果是:

Installing symfony/framework-standard-edition (v2.1.0)
  - Installing symfony/framework-standard-edition (v2.1.0)
    Downloading: 100%

    Created project in symfony
    Loading composer repositories with package information
    Installing dependencies from lock file
    Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - Installation request for symfony/symfony == 2.1.9999999.9999999-dev -> satisfiable by                                               symfony/symfony 2.1.x-dev.
        - Can only install one of: symfony/symfony dev-master, symfony/symfony 2.1.x-dev.
        - Installation request for symfony/symfony == 9999999-dev -> satisfiable by symfony/sym                                              fony dev-master.

所以我做一个 php composer.phar update 和依赖安装没有错误。

So I do a php composer.phar update and the dependencies was installed without errors.

但我注意到,大多数软件包没有稳定的版本。例如doctrine / common(2.3.x-dev),这里是完整的列表

But I noticed that most bundles have no stable version. For example doctrine/common (2.3.x-dev), here is the full list

Loading composer repositories with package information
Updating dependencies
  - Installing doctrine/common (2.3.x-dev 605b1b8)
    Cloning 605b1b8b5a7bc8daf9111fb35483e5708e30de35

  - Installing doctrine/dbal (2.3.x-dev 239630b)
    Cloning 239630b61f03f39d198441eced1bfffb7b0e61d1

  - Installing twig/twig (dev-master 68b8c46)
    Cloning 68b8c4619c5bbe82bd345fe56070dec8c356610a

  - Installing symfony/symfony (2.1.x-dev e7059b4)
    Cloning e7059b44c78ca8e1e892adb4d93b5a482f4eb9b3

  - Installing swiftmailer/swiftmailer (dev-master e12e4ef)
    Cloning e12e4ef3a9d6dd60fb734a01984a6e6627aea764

  - Installing doctrine/orm (2.3.x-dev 4d9f24b)
    Cloning 4d9f24b2eef3af3a3e76c773994c19bbb0706f88

  - Installing doctrine/doctrine-bundle (dev-master v1.0.0)
    Cloning v1.0.0

  - Installing twig/extensions (dev-master f904575)
    Cloning f904575642b1213db69b4a98f08397e722ba1cae

  - Installing kriswallsmith/assetic (dev-master dfbb776)
    Cloning dfbb776288baf9319d1693195af2cb6e00729901

  - Installing symfony/assetic-bundle (dev-master 4e7e8a0)
    Cloning 4e7e8a039fa19434f04558473adbb201118af942

  - Installing symfony/swiftmailer-bundle (dev-master d2eae93)
    Cloning d2eae9385c029cbac031a90e6d2abc74b889a562

  - Installing monolog/monolog (dev-master a929570)
    Cloning a929570bb7688b39fefe4106f0ecf0ac35f37647

  - Installing symfony/monolog-bundle (dev-master v2.1.0-RC2)
    Cloning v2.1.0-RC2

  - Installing sensio/distribution-bundle (dev-master 9892129)
    Cloning 98921298951598e8707258cba2b6180b96faa91c

  - Installing sensio/framework-extra-bundle (dev-master v2.1.0)
    Cloning v2.1.0

  - Installing sensio/generator-bundle (dev-master v2.1.0-RC2)
    Cloning v2.1.0-RC2

  - Installing jms/metadata (1.1.1)
    Downloading: 100%

  - Installing jms/cg (1.0.0)
    Downloading: 100%

  - Installing jms/aop-bundle (1.0.0)
    Downloading: 100%

  - Installing jms/di-extra-bundle (1.1.x-dev af21952)
    Cloning af219527024c584d7311aa855d7522429c5bdb67

  - Installing jms/security-extra-bundle (1.2.x-dev 9ab6ace)
    Cloning 9ab6aceda50fc7a2b07d741ba4b3f0695508afcb

1a)这是对的吗?还是有另一个解决方案?我的意思是使用稳定且不在开发模式下的软件包

第二天我又做一个作曲家更新, libs对于dev-master分支,在最后一天内有新的更改。

1b)所以我应该在开发我的应用程序时定期更新一个作曲家,合并新的bug修复等等? / strong>

The next day I do again an composer update and noticed that some libs were updated: all libs for dev-master branch which has new changes within the last day.
1b) So I should do a composer update in regular intervals while developing my app, to merge new bugfixes, etc?

$ php composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Updating swiftmailer/swiftmailer dev-master (e12e4e => c97353)
    Checking out c97353b1ebffe25a224146f69d17efe24c093def

  - Updating monolog/monolog dev-master (a92957 => e5bf7b)
    Checking out e5bf7ba5d1df622b68d004b3c0277bc94286e1b7

  - Updating friendsofsymfony/user-bundle dev-master (24edb2 => 878b7c)
    Checking out 878b7c8320159fb09e8e94d446c498b00142b206

  - Updating sonata-project/notification-bundle dev-master (5e7b50 => 9cef7d)
    Checking out 9cef7d224f224b4e4327f200f9bd57b798d4ab0a

  - Updating knplabs/gaufrette dev-master (861110 => 5ac439)
    Checking out 5ac439cd46eb461043e6bb73dae717528f674a57

  - Updating sonata-project/media-bundle dev-master (d04a61 => 233511)
    Checking out 2335114dab6ea9680d174df157f5a7b4551a54dc

因为我没有找到另一个解决方案我继续和安装FOS UserBundle通过添加这行friendsofsymfony / user-bundle:*到composer.json 。
我做整个安装的东西,它的工作完美。

Because I don't found out another solution I continue and install FOS UserBundle by adding this line "friendsofsymfony/user-bundle": "*" to the composer.json. I do the whole installation stuff and it works perfectly.

然后我开始安装Sonata AdminBundle添加sonata-project / admin-bundle:dev-master添加到composer.json。我选择了dev-master版本,因为在 http://packagist.org/packages/sonata-project/admin-bundle 我发现版本2.0.x-dev不适用于symfony2.1。

此外,AdminBundle对knplabs / knp-menu-bundle有一个depdency:1.1。*

http://packagist.org/packages/knplabs/knp-menu-bundle 我看到版本v1.1.0有knplabs / knp菜单的另一个依赖:1.1。*

然后在 http://packagist.org/packages/knplabs/knp-menu 我发现以1.1开头的4个版本:

Then I start to install the Sonata AdminBundle by adding "sonata-project/admin-bundle": "dev-master" to the composer.json. I chose the dev-master version because on http://packagist.org/packages/sonata-project/admin-bundle I found out that the version 2.0.x-dev is not for symfony2.1.
Furthermore the AdminBundle has a depdency for knplabs/knp-menu-bundle: 1.1.*
On http://packagist.org/packages/knplabs/knp-menu-bundle I see for the version v1.1.0 that there is another dependency for knplabs/knp-menu: 1.1.*
Then on http://packagist.org/packages/knplabs/knp-menu I found 4 versions that begins with 1.1:


  • 1.1.x-dev

  • v1.1.2

  • v1.1.1

  • 1.0
  • 1.1.x-dev
  • v1.1.2
  • v1.1.1
  • v1.1.0

2a)如果存在前导 v 版本号之前?

2a) Is there a difference if there is a leading v before the version number?

2b)当依赖关系为1.1 *时,将使用这四个版本中的哪一个版本? >

2b) Which version will be used of these four, when the dependency is 1.1* ?

当我开始加载管理包bunds时,我看到结果:

When I start to load the admin bundle deps I see the result:

$ php composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Installing knplabs/knp-menu (1.1.x-dev v1.1.2)
    Cloning v1.1.2

  - Installing knplabs/knp-menu-bundle (v1.1.0)
    Downloading: 100%

  - Installing sonata-project/admin-bundle (dev-master 20d5e4a)
    Cloning 20d5e4a659bddb5fc0bcfc4755643dbc4e3f7ec1

我安装了一些更多的奏鸣曲doctrine-orm-admin-bundle,user-bundle,page-bundle,media-bundle),出现错误

I install some more sonata bundles (doctrine-orm-admin-bundle, user-bundle, page-bundle, media-bundle) and there was an error

  - Installing imagine/imagine (v0.3.0)
    Downloading: 100%



  [ErrorException]
  rename(C:\wamp\www\symfony\vendor/imagine/Imagine/avalanche123-Imagine-a23b4f5,afcc946468d0cf073686fe7e1ae19eb2): access denied
   (code: 5)

3)但是当我重复这一步,错误消失了。这是否正常?

$ php composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Installing imagine/imagine (v0.3.0)
    Downloading: 100%

  - Installing knplabs/gaufrette (dev-master 8611109)
    Cloning 8611109aeb0bd43fd88485c20fec7fc85b021b84

  - Installing sonata-project/media-bundle (dev-master d04a617)
    Cloning d04a617d81383a6e1ba65ee99c2ea4379e7daf4e

然后我继续配置sonata admin bundle。我添加一个创建一个Post实体和一个PostAdmin并为其配置服务(btw:服务配置有点差),注意到我忘了安装Knp菜单(错误是:不存在的服务knp_menu.factory

Then I continued with the configuration of sonata admin bundle. After I add a create a Post entity and a PostAdmin and configure a service for it (btw: the service configuration is a little bit poor), noticed that I forget to install the Knp Menu (the error was: non-existent service "knp_menu.factory)

我会去https://github.com/KnpLabs/KnpMenuBundle/blob/master/Resources/doc/index.md ,并查看指示详情以进行安装。由于smyfony2.1。在autoload.php中的 $ loader 没有 registerNamespaces 函数了,因为这不是UniversalClassLoader类,它的composer类加载器所以我必须创建一个自己的UniversalClassLoader实例,路径是完全不同的,现在有一个父 knplabs 目录

I go on https://github.com/KnpLabs/KnpMenuBundle/blob/master/Resources/doc/index.md and see the instruction details to install it. Butt there were outdated. Since smyfony2.1. the $loader in the autoload.php has no registerNamespaces function anymore, because this is not the UniversalClassLoader class, its the composer classloader. So I have to create an own UniversalClassLoader instance. And the paths are completly different, there is now a parent knplabs directory and the sub directory also changed.

use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = require __DIR__.'/../vendor/autoload.php';

// intl
if (!function_exists('intl_get_error_code')) {
    require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';

    $loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}

$universalLoader = new UniversalClassLoader();
$universalLoader->registerNamespaces(array(
        'Knp\Menu' => __DIR__.'../vendor/knplabs/knp-menu/src',
        'Knp\Bundle' => __DIR__.'/../vendor/knplabs/knp-menu-bundle'
));
$universalLoader->register();


AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

return $loader;

4)为什么KnpMenu安装结构过时,为什么只有一个主分支github,并且在 http://packagist.org 上存在的版本没有任何内容?

4) Why is the KnpMenu install construction outdated and why there is only a master branch on github and nothing for the versions which exist on http://packagist.org?

我是symfony2和作曲家的新人,有时很难理解这些东西。

I'm new to symfony2 and composer and it's sometimes really hard to understand this whole stuff.

推荐答案

$ b

1a)这是对的吗?还是有另一个解决方案?

1a) Is this right? Or is there another solution? I mean to use bundles which are stable and not in dev mode

Symfony21将为您选择最适合的版本。您可以在 composer.json symfony / framework-standard-edition 包的<$ c> 文件( symfony / symfony-standard

Symfony21 will standard choose the best version for you. You can see these versions in the composer.json file of the symfony/framework-standard-edition package (symfony/symfony-standard on github).

如你所见,它使用 2.1。* 版本,而不是 dev-master 版本,但是因为最新版本的软件包以 2.1 开头,它会加载。后来,用symfony2.2它不应该使用 dev-master ,但是最新的 2.1

As you can see it uses the 2.1.* versions and not the dev-master versions, but because the latest version of the package begins with 2.1 it will load the dev-master. Later, with symfony2.2 it shouldn't use the dev-master, but the latest 2.1 version of the package.

如果你想要一个静态版本,你可以用你想要的subversion替换 * 因为你没有得到错误修复。

If you want a static version you can just replace the * with the subversion you want, but I don't recommend this because you don't get the bug fixes.


1b)因此我应该在定期进行作曲家更新我的应用程序,合并新的错误修正等等。

1b) So I should do a composer update in regular intervals while developing my app, to merge new bugfixes, etc?

是的,它是不时更新你的依赖。例如,如果您认为您发现了一个错误或者如果您在生产中推送它。

Yes, it is good to update your dependencies from time to time. For instance if you think you spot a bug or if you push it in production.


2a)如果版本号之前有前导v,那么是否有区别?

2a) Is there a difference if there is a leading v before the version number?

我们可以在 packagist文档(在管理软件包版本下)没有区别。你可以使用它们,如果你使用 2.1.4 它会寻找一个 2.1.4 版本或 v2.1.4

As we can read in the packagist documentation (under Managing package versions) there is no difference. You can use them both and if you use 2.1.4 it will look for a 2.1.4 version or v2.1.4.


2b)将使用这四个版本,依赖是1.1。*?

2b) Which version will be used of these four, when the dependency is 1.1.* ?

最新的 1.1 例如,如果你 foobar 包有这些版本:1.1.1,1.1.2 .. 1.1.6。
并且您需要 1.1。* 将安装最新版本( 1.1.6 )。

The latest 1.1 subversion. For instance if you foobar package has these versions: 1.1.1, 1.1.2 .. 1.1.6. And you require 1.1.* the latest (1.1.6) will be installed.


3)但是当我重复这一步时,错误消失了。这是正常的吗?

3) but when I repeat the step the error was gone. Is this normal?

看起来CLI无法访问该文件,您可能在程序中打开它。

It looks like the CLI can't access the file, you maybe opened it in a program. When you tried it the second time it had access.


4)为什么KnpMenu安装结构过时,为什么只有主分支在github上,并且在 http://packagist.org 上存在的版本没有任何内容?

4) Why is the KnpMenu install construction outdated and why there is only a master branch on github and nothing for the versions which exist on http://packagist.org?

第一个问题:我不知道为什么文档是过时的。你应该进入 vendor / composer / autoload_namespaces.php 文件,并将命名空间放在那里,那么它应该工作。或者,更好的选项,将这些命名空间添加到 composer.json 文件中的 require 设置。有关详情,请参见作曲家自动加载文档

First question: I don't know why the documentation is outdated. You should go into the vendor/composer/autoload_namespaces.php file and put the namespaces there, then it should work. Or, the better option, add these namespaces to the require setting in the composer.json file. See the composer autoload docs for more information.

第二个问题:它也使用了github上的标签

Second question: It uses the tags on github too.

这篇关于symfony2.1捆绑版本混乱,用于symfony和sonata admin / knp菜单捆绑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆