在 symfony 3.4 上安装 FOSUserBundle 时出错

Error installing FOSUserBundle on symfony 3.4

在官方文档中它说这是第一步

$ composer require friendsofsymfony/user-bundle "~2.0"

这个return我这个错误

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install friendsofsymfony/user-bundle v2.1.2
    - Conclusion: don't install friendsofsymfony/user-bundle v2.1.1
    - Conclusion: don't install friendsofsymfony/user-bundle v2.1.0
    - Conclusion: don't install friendsofsymfony/user-bundle v2.0.2
    - Conclusion: don't install friendsofsymfony/user-bundle v2.0.1
    - Conclusion: remove paragonie/random_compat v9.99.99
    - Installation request for friendsofsymfony/user-bundle ~2.0 -> satisfiable by friendsofsymfony/user-bundle[v2.0.0, v2.0.1, v2.0.2, v2.1.0, v2.1.1, v2.1.2].
    - Conclusion: don't install paragonie/random_compat v9.99.99
    - friendsofsymfony/user-bundle v2.0.0 requires paragonie/random_compat ^1 || ^2 -> satisfiable by paragonie/random_compat[1.0.10, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, v1.0.0, v1.0.1, v1.2.0, v1.2.1, v1.2.2, v1.2.3, v1.3.0, v1.3.1, v1.4.0, v1.4.1, v1.4.2, v1.4.3, v2.0.0, v2.0.1, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9].
    - Can only install one of: paragonie/random_compat[1.0.10, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.2, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.3, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.4, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.5, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.6, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.7, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.8, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.0.9, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.2, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.3, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.4, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.5, v9.99.99].
    - Can only install one of: paragonie/random_compat[1.1.6, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.0.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.0.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.2.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.2.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.2.2, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.2.3, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.3.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.3.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.4.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.4.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.4.2, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.4.3, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.0, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.1, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.10, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.11, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.12, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.13, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.14, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.15, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.16, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.17, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.2, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.3, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.4, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.5, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.6, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.7, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.8, v9.99.99].
    - Can only install one of: paragonie/random_compat[v2.0.9, v9.99.99].
    - Installation request for paragonie/random_compat (locked at v9.99.99) -> satisfiable by paragonie/random_compat[v9.99.99].


Installation failed, reverting ./composer.json to its original content.

这是我安装的包列表

behat/transliterator                     v1.2.0   String transliterator
cocur/slugify                            v3.1     Converts a string into a slug.
composer/ca-bundle                       1.1.2    Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
doctrine/annotations                     v1.6.0   Docblock Annotations Parser
doctrine/cache                           v1.7.1   Caching library offering an object-oriented API for many cache backends
doctrine/collections                     v1.5.0   Collections Abstraction library
doctrine/common                          v2.9.0   Common Library for Doctrine projects
doctrine/dbal                            v2.8.0   Database Abstraction Layer
doctrine/doctrine-bundle                 1.9.1    Symfony DoctrineBundle
doctrine/doctrine-cache-bundle           1.3.3    Symfony Bundle for Doctrine Cache
doctrine/event-manager                   v1.0.0   Doctrine Event Manager component
doctrine/inflector                       v1.3.0   Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                    1.1.0    A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                           v1.0.1   Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm                             v2.6.2   Object-Relational-Mapper for PHP
doctrine/persistence                     v1.0.0   Doctrine Persistence abstractions.
doctrine/reflection                      v1.0.0   Doctrine Reflection component
fig/link-util                            1.0.0    Common utility implementations for HTTP links
gedmo/doctrine-extensions                v2.4.36  Doctrine2 behavioral extensions
incenteev/composer-parameter-handler     v2.1.3   Composer script handling your ignored parameter file
jdorn/sql-formatter                      v1.2.17  a PHP SQL highlighting library
knplabs/knp-menu                         2.3.0    An object oriented menu library
knplabs/knp-menu-bundle                  v2.2.1   This bundle provides an integration of the KnpMenu library
monolog/monolog                          1.23.0   Sends your logs to files, sockets, inboxes, databases and various web services
paragonie/random_compat                  v9.99.99 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
psr/cache                                1.0.1    Common interface for caching libraries
psr/container                            1.0.0    Common Container Interface (PHP FIG PSR-11)
psr/link                                 1.0.0    Common interfaces for HTTP links
psr/log                                  1.0.2    Common interface for logging libraries
psr/simple-cache                         1.0.1    Common interfaces for simple caching
sensio/distribution-bundle               v5.0.22  Base bundle for Symfony Distributions
sensio/framework-extra-bundle            v5.2.0   This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle                  v3.1.7   This bundle generates code for you
sensiolabs/security-checker              v4.1.8   A security checker for your composer.lock
sonata-project/admin-bundle              3.38.0   The missing Symfony Admin Generator
sonata-project/block-bundle              3.12.1   Symfony SonataBlockBundle
sonata-project/cache                     2.0.1    Cache library
sonata-project/core-bundle               3.11.2   Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1    Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.6.1    Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.9.1    Lightweight Exporter library
sonata-project/intl-bundle               2.5.0    Symfony SonataIntlBundle
stof/doctrine-extensions-bundle          v1.3.0   Integration of the gedmo/doctrine-extensions with Symfony2
swiftmailer/swiftmailer                  v5.4.12  Swiftmailer, free feature-rich PHP mailer
symfony/asset                            v4.1.3   Symfony Asset Component
symfony/monolog-bundle                   v3.3.0   Symfony MonologBundle
symfony/phpunit-bridge                   v3.4.14  Symfony PHPUnit Bridge
symfony/polyfill-apcu                    v1.9.0   Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype                   v1.9.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-icu                v1.9.0   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                v1.9.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                   v1.9.0   Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                   v1.9.0   Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                    v1.9.0   Symfony utilities for portability of PHP codes
symfony/security-acl                     v3.0.1   Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle               v2.6.7   Symfony SwiftmailerBundle
symfony/symfony                          v3.4.14  The Symfony PHP framework
twig/extensions                          v1.5.2   Common additional features for Twig that do not directly belong in core
twig/twig                                v2.5.0   Twig, the flexible, fast, and secure template language for PHP

这是一个已知的错误,因为 random_compat 库最近由于某种原因更新为一个奇怪的 9.99.99 版本,并且一个包有一个错误声明的依赖项。您可以做的是在您自己的项目中明确要求 ^2.0 版本。

运行:

composer require paragonie/random_compat ^2.0

或者您可以将 composer.json 修改为

"require": {
    ...
    "paragonie/random_compat": "^2.0",
    ...
},

然后,正常安装您的包。