Symfony 4 为奏鸣曲管理包安装 sensio/generator-bundle 时出错

Posted

技术标签:

【中文标题】Symfony 4 为奏鸣曲管理包安装 sensio/generator-bundle 时出错【英文标题】:Symfony 4 error installing sensio/generator-bundle for sonata admin bundle 【发布时间】:2019-01-18 02:27:09 【问题描述】:

我从奏鸣曲第 4 版开始。 3 效果很好,但是在第 4 版中,很多事情发生了变化。 过了一会儿,我找到了here 如何安装它,但它返回了下一个错误。

  Problem 1
    - sensio/generator-bundle v3.1.7 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.6 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.5 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.4 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.3 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.2 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle v3.1.1 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - sensio/generator-bundle 3.1.0 requires symfony/framework-bundle ~2.7|~3.0 -> satisfiable by symfony/framework-bundle[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.4.0, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.2, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9] but these conflict with your requirements or minimum-stability.
    - Installation request for sensio/generator-bundle ^3.1 -> satisfiable by sensio/generator-bundle[3.1.0, v3.1.1, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7].

我尝试强制执行第 4 版,但它返回给我

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package sensio/generator-bundle ^4.0 exists as sensio/generator-bundle[2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.4.x-dev, 2.5.x-dev, 3.1.0, dev-master, 3.1.x-dev, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.22, v2.0.23, v2.1.0, v2.1.0-RC2, v2.1.10, v2.1.11, v2.1.3, v2.1.4, v2.1.5, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.0-BETA1, v2.2.0-BETA2, v2.2.0-RC1, v2.2.0-RC2, v2.2.0-RC3, v2.2.1, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.3.0, v2.3.0-BETA1, v2.3.0-BETA2, v2.3.0-RC1, v2.3.1, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.5.0, v2.5.1, v2.5.2, v2.5.3, v3.0.0, v3.0.1, v3.0.10, v3.0.11, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.1, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7] but these are rejected by your constraint.

这是所有捆绑包的信息

$ php composer.phar show
behat/transliterator                     v1.2.0     String transliterator
cocur/slugify                            v3.1       Converts a string into a slug.
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/doctrine-migrations-bundle      v1.3.1     Symfony DoctrineMigrationsBundle
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/migrations                      v1.8.1     Database Schema migrations using Doctrine DBAL
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
easycorp/easy-log-handler                v1.0.7     A handler for Monolog that optimizes log messages to be processed by humans instead of software. Improve you...
egulias/email-validator                  2.1.4      A library for validating emails against several RFCs
fig/link-util                            1.0.0      Common utility implementations for HTTP links
gedmo/doctrine-extensions                v2.4.36    Doctrine2 behavioral extensions
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
nikic/php-parser                         v4.0.3     A PHP parser written in PHP
ocramius/package-versions                1.3.0      Composer plugin that provides efficient querying for installed package versions (no runtime IO)
ocramius/proxy-manager                   2.1.1      A library providing utilities to generate, instantiate and generally operate with Object Proxies
phpdocumentor/reflection-common          1.0.1      Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock        4.3.0      With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve infor...
phpdocumentor/type-resolver              0.4.0     
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/framework-extra-bundle            v5.2.0     This bundle provides a way to configure your controllers with annotations
sonata-project/admin-bundle              3.37.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
stof/doctrine-extensions-bundle          v1.3.0     Integration of the gedmo/doctrine-extensions with Symfony2
swiftmailer/swiftmailer                  v6.1.2     Swiftmailer, free feature-rich PHP mailer
symfony/asset                            v4.1.3     Symfony Asset Component
symfony/browser-kit                      v4.1.3     Symfony BrowserKit Component
symfony/cache                            v4.1.3     Symfony Cache component with PSR-6, PSR-16, and tags
symfony/class-loader                     v3.4.14    Symfony ClassLoader Component
symfony/config                           v4.1.3     Symfony Config Component
symfony/console                          v4.1.3     Symfony Console Component
symfony/css-selector                     v4.1.3     Symfony CssSelector Component
symfony/debug                            v4.1.3     Symfony Debug Component
symfony/debug-bundle                     v4.1.3     Symfony DebugBundle
symfony/debug-pack                       v1.0.5     A debug pack for Symfony projects
symfony/dependency-injection             v4.1.3     Symfony DependencyInjection Component
symfony/doctrine-bridge                  v4.1.3     Symfony Doctrine Bridge
symfony/dom-crawler                      v4.1.3     Symfony DomCrawler Component
symfony/dotenv                           v4.1.3     Registers environment variables from a .env file
symfony/event-dispatcher                 v4.1.3     Symfony EventDispatcher Component
symfony/expression-language              v4.1.3     Symfony ExpressionLanguage Component
symfony/filesystem                       v4.1.3     Symfony Filesystem Component
symfony/finder                           v4.1.3     Symfony Finder Component
symfony/flex                             v1.0.89    Composer plugin for Symfony
symfony/form                             v4.1.3     Symfony Form Component
symfony/framework-bundle                 v4.1.3     Symfony FrameworkBundle
symfony/http-foundation                  v4.1.3     Symfony HttpFoundation Component
symfony/http-kernel                      v4.1.3     Symfony HttpKernel Component
symfony/inflector                        v4.1.3     Symfony Inflector Component
symfony/intl                             v4.1.3     A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/lts                              dev-master Enforces Long Term Supported versions of Symfony components
symfony/maker-bundle                     v1.6.0     Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget a...
symfony/monolog-bridge                   v4.1.3     Symfony Monolog Bridge
symfony/monolog-bundle                   v3.3.0     Symfony MonologBundle
symfony/options-resolver                 v4.1.3     Symfony OptionsResolver Component
symfony/orm-pack                         v1.0.5     A pack for the Doctrine ORM
symfony/phpunit-bridge                   v4.1.3     Symfony PHPUnit Bridge
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-php72                   v1.9.0     Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process                          v4.1.3     Symfony Process Component
symfony/profiler-pack                    v1.0.3     A pack for the Symfony web profiler
symfony/property-access                  v4.1.3     Symfony PropertyAccess Component
symfony/property-info                    v4.1.3     Symfony Property Info Component
symfony/routing                          v4.1.3     Symfony Routing Component
symfony/security                         v4.1.3     Symfony Security Component
symfony/security-acl                     v3.0.1     Symfony Security Component - ACL (Access Control List)
symfony/security-bundle                  v4.1.3     Symfony SecurityBundle
symfony/serializer                       v4.1.3     Symfony Serializer Component
symfony/serializer-pack                  v1.0.1     A pack for the Symfony serializer
symfony/stopwatch                        v4.1.3     Symfony Stopwatch Component
symfony/swiftmailer-bundle               v3.2.2     Symfony SwiftmailerBundle
symfony/templating                       v4.1.3     Symfony Templating Component
symfony/test-pack                        v1.0.2     A pack for functional testing within a Symfony app
symfony/translation                      v4.1.3     Symfony Translation Component
symfony/twig-bridge                      v4.1.3     Symfony Twig Bridge
symfony/twig-bundle                      v4.1.3     Symfony TwigBundle
symfony/validator                        v4.1.3     Symfony Validator Component
symfony/var-dumper                       v4.1.3     Symfony mechanism for exploring and dumping PHP variables
symfony/web-link                         v4.1.3     Symfony WebLink Component
symfony/web-profiler-bundle              v4.1.3     Symfony WebProfilerBundle
symfony/web-server-bundle                v4.1.3     Symfony WebServerBundle
symfony/yaml                             v4.1.3     Symfony Yaml Component
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
webmozart/assert                         1.3.0      Assertions to validate method input/output with nice error messages.
zendframework/zend-code                  3.3.0      provides facilities to generate arbitrary code using an object oriented interface
zendframework/zend-eventmanager          3.2.1      Trigger and listen to events within a PHP application

编辑

这里是 composer.json


    "type": "project",
    "license": "proprietary",
    "require": 
        "php": "^7.1.3",
        "ext-iconv": "*",
        "sensio/framework-extra-bundle": "^5.1",
        "sonata-project/admin-bundle": "^3.37",
        "sonata-project/doctrine-orm-admin-bundle": "^3.6",
        "stof/doctrine-extensions-bundle": "^1.3",
        "symfony/asset": "^4.1",
        "symfony/console": "^4.1",
        "symfony/expression-language": "^4.1",
        "symfony/flex": "^1.0",
        "symfony/form": "^4.1",
        "symfony/framework-bundle": "^4.1",
        "symfony/lts": "^4@dev",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "^1.0",
        "symfony/process": "^4.1",
        "symfony/security-bundle": "^4.1",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/twig-bundle": "^4.1",
        "symfony/validator": "^4.1",
        "symfony/web-link": "^4.1",
        "symfony/web-server-bundle": "^4.1",
        "symfony/yaml": "^4.1"
    ,
    "require-dev": 
        "symfony/debug-pack": "*",
        "symfony/dotenv": "^4.1",
        "symfony/maker-bundle": "^1.6",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "^1.0"
    ,
    "config": 
        "preferred-install": 
            "*": "dist"
        ,
        "sort-packages": true
    ,
    "autoload": 
        "psr-4": 
            "App\\": "src/"
        
    ,
    "autoload-dev": 
        "psr-4": 
            "App\\Tests\\": "tests/"
        
    ,
    "replace": 
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    ,
    "scripts": 
        "auto-scripts": 
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        ,
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    ,
    "conflict": 
        "symfony/symfony": "*"
    ,
    "extra": 
        "symfony": 
            "allow-contrib": false
        
    

【问题讨论】:

你能提供你的composer.json吗? 好了,有什么想法吗? 【参考方案1】:

删除 composer.lock 删除作曲家缓存 清除供应商文件夹

然后

composer update

我用你的 composer.json 成功地为空 Symfony 4.1 项目做了composer update

【讨论】:

这是一个清除程序,我为什么要再次清除它?这是微软的解决方案吗? 我用你的作曲家 json 做了作曲家更新,并没有注意到那种问题。所以我认为这是某种混乱的缓存问题。尝试清除作曲家缓存并至少删除 composer.lock 他的composer.json 不需要generator-bundle【参考方案2】:

这里的问题很简单:如果你需要 3.1 版的生成器包(或者通常每个3.x 版本)你必须有 symfony 3,因为这个包不兼容 sf4。所以你的第一次尝试不会成功。

如果您尝试要求此捆绑包的版本 4,则会收到错误,因为没有带有 4 标签的版本。

事实上,this bundle is replaced with MakerBundle 可以用于 symfony 4 项目

【讨论】:

感谢您的回答。我看到了,但是使用 MakerBundle 你不能做奏鸣曲管理员,至少目前不能

以上是关于Symfony 4 为奏鸣曲管理包安装 sensio/generator-bundle 时出错的主要内容,如果未能解决你的问题,请参考以下文章

无法使用 symfony 5 安装奏鸣曲管理员

Symfony 4 中的奏鸣曲媒体包模板

Symfony 3.2.7 和奏鸣曲媒体包安装

Symfony 2 Sonata 媒体包:在没有奏鸣曲管理员的情况下保存媒体文件图像

在 Symfony 4 中使用命令行生成管理员奏鸣曲

在 Sonata symfony 4 中创建管理员用户