Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 4,迁移到生产,命令;composer安装--无开发“;失败(ClassNotFoundException:WebProfilerBundle)_Php_Symfony_Composer Php_Symfony4 - Fatal编程技术网

Php Symfony 4,迁移到生产,命令;composer安装--无开发“;失败(ClassNotFoundException:WebProfilerBundle)

Php Symfony 4,迁移到生产,命令;composer安装--无开发“;失败(ClassNotFoundException:WebProfilerBundle),php,symfony,composer-php,symfony4,Php,Symfony,Composer Php,Symfony4,En dev environment当我运行命令composer install时,我没有任何问题。我想在另一台服务器(prod服务器)上部署我的symfony应用程序,但是,当我运行命令composer install--no dev时,我收到一个错误,我没有发现/理解问题所在 记录如下: 使用包信息加载composer存储库 从锁文件安装依赖项 包操作:118次安装,0次更新,0次删除 -安装ocramius/软件包版本(1.3.0):从缓存加载 -安装symfony/flex(v1.1.8

En dev environment当我运行命令
composer install
时,我没有任何问题。我想在另一台服务器(prod服务器)上部署我的symfony应用程序,但是,当我运行命令
composer install--no dev
时,我收到一个错误,我没有发现/理解问题所在

记录如下:

使用包信息加载composer存储库
从锁文件安装依赖项
包操作:118次安装,0次更新,0次删除
-安装ocramius/软件包版本(1.3.0):从缓存加载
-安装symfony/flex(v1.1.8):从缓存加载
-安装symfony/yaml(v4.1.10):从缓存加载
-安装symfony/finder(v4.1.10):从缓存加载
- ...
-安装symfony/web链接(v4.1.10):从缓存加载
-安装symfony/asset(v4.1.10):从缓存加载
-安装symfony/webpack encore pack(v1.0.3):从缓存加载
生成自动加载文件
ocramius/包版本:正在生成版本类。。。
ocramius/包版本:…生成版本类完成
正在执行脚本缓存:清除[KO]
[KO]
脚本缓存:清除返回的错误代码为255
!!  PHP致命错误:未捕获Symfony\Component\Debug\Exception\ClassNotFoundException:试图从命名空间“Symfony\Bundle\WebProfilerBundle”加载类“WebProfilerBundle”。
!!  您是否忘记了另一个名称空间的“use”语句?在/var/www/myapp/src/Kernel.php:33中
!!  堆栈跟踪:
!!  #0/var/www/myapp/vendor/symfony/http-kernel/kernel.php(405):App\kernel->registerBundles()
!!  #1/var/www/myapp/vendor/symfony/http kernel/kernel.php(120):symfony\Component\HttpKernel\kernel->initializeBundles()
!!  #2/var/www/myapp/vendor/symfony/frameworkbundle/Console/Application.php(65):symfony\Component\HttpKernel\Kernel->boot()
!!  #3/var/www/myapp/vendor/symfony/console/Application.php(145):symfony\Bundle\FrameworkBundle\console\Application->doRun(对象(symfony\Component\console\Input\ArgvInput),对象(symfony\Component\console\Output\ConsoleOutput))
!!  #4/var/www/myapp/bin/console(39):Symfony\Component\console\Application->run(对象(Symfony\Component\console\Input\ArgvInput))
!!  #5{main}
!!    在第33行的/var/www/myapp/src/Kernel.php中抛出
!!  
Script@auto scripts是通过post-install cmd调用的
My composer.json:

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "codeception/codeception": "^2.5",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "friendsofsymfony/jsrouting-bundle": "^2.2",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "*",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/expression-language": "*",
        "symfony/flex": "^1.1",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "*",
        "symfony/process": "*",
        "symfony/security-bundle": "*",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "symfony/web-link": "*",
        "symfony/webpack-encore-pack": "^1.0",
        "symfony/yaml": "*"
    },
    "require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.0",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "^1.0",
        "symfony/web-server-bundle": "*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "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,
            "require": "4.1.*"
        }
    }
}
谢谢你的帮助/提示!我不是一个伟大的作曲家用户:/

编辑,命令的完整输出
composer install--no dev

Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 118 installs, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.3.0): Loading from cache
  - Installing symfony/flex (v1.1.8): Loading from cache
  - Installing symfony/yaml (v4.1.10): Loading from cache
  - Installing symfony/finder (v4.1.10): Loading from cache
  - Installing symfony/event-dispatcher (v4.1.10): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache
  - Installing symfony/dom-crawler (v4.1.10): Loading from cache
  - Installing symfony/css-selector (v4.1.10): Loading from cache
  - Installing symfony/console (v4.1.10): Loading from cache
  - Installing symfony/browser-kit (v4.1.10): Loading from cache
  - Installing ralouphie/getallheaders (2.0.5): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing guzzlehttp/psr7 (1.5.2): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.3.3): Loading from cache
  - Installing symfony/process (v4.1.10): Loading from cache
  - Installing facebook/webdriver (1.6.0): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing sebastian/global-state (2.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.0): Loading from cache
  - Installing sebastian/environment (4.0.1): Loading from cache
  - Installing sebastian/diff (3.0.1): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing phpunit/php-timer (2.0.0): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing theseer/tokenizer (1.1.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-token-stream (3.0.1): Loading from cache
  - Installing phpunit/php-code-coverage (6.1.4): Loading from cache
  - Installing webmozart/assert (1.4.0): Loading from cache
  - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
  - Installing phpdocumentor/type-resolver (0.4.0): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.0): Loading from cache
  - Installing doctrine/instantiator (1.1.0): Loading from cache
  - Installing phpspec/prophecy (1.8.0): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing myclabs/deep-copy (1.8.1): Loading from cache
  - Installing phpunit/phpunit (7.5.2): Loading from cache
  - Installing codeception/stub (2.0.4): Loading from cache
  - Installing codeception/phpunit-wrapper (7.6.1): Loading from cache
  - Installing behat/gherkin (v4.6.0): Loading from cache
  - Installing codeception/codeception (2.5.2): Loading from cache
  - Installing doctrine/lexer (v1.0.1): Loading from cache
  - Installing doctrine/annotations (v1.6.0): Loading from cache
  - Installing doctrine/reflection (v1.0.0): Loading from cache
  - Installing doctrine/event-manager (v1.0.0): Loading from cache
  - Installing doctrine/collections (v1.5.0): Loading from cache
  - Installing doctrine/cache (v1.8.0): Loading from cache
  - Installing doctrine/persistence (v1.1.0): Loading from cache
  - Installing doctrine/inflector (v1.3.0): Loading from cache
  - Installing doctrine/common (v2.10.0): Loading from cache
  - Installing symfony/doctrine-bridge (v4.1.10): Loading from cache
  - Installing doctrine/doctrine-cache-bundle (1.3.5): Loading from cache
  - Installing symfony/routing (v4.1.10): Loading from cache
  - Installing symfony/http-foundation (v4.1.10): Loading from cache
  - Installing psr/log (1.1.0): Loading from cache
  - Installing symfony/debug (v4.1.10): Loading from cache
  - Installing symfony/http-kernel (v4.1.10): Loading from cache
  - Installing symfony/filesystem (v4.1.10): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/dependency-injection (v4.1.10): Loading from cache
  - Installing symfony/config (v4.1.10): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing symfony/cache (v4.1.10): Loading from cache
  - Installing symfony/framework-bundle (v4.1.10): Loading from cache
  - Installing jdorn/sql-formatter (v1.2.17): Loading from cache
  - Installing doctrine/dbal (v2.9.2): Loading from cache
  - Installing doctrine/doctrine-bundle (1.10.1): Loading from cache
  - Installing doctrine/data-fixtures (v1.3.1): Loading from cache
  - Installing doctrine/doctrine-fixtures-bundle (3.1.0): Loading from cache
  - Installing symfony/stopwatch (v4.1.10): Loading from cache
  - Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
  - Installing zendframework/zend-code (3.3.1): Loading from cache
  - Installing ocramius/proxy-manager (2.2.2): Loading from cache
  - Installing doctrine/migrations (v2.0.0): Loading from cache
  - Installing egulias/email-validator (2.1.7): Loading from cache
  - Installing willdurand/jsonp-callback-validator (v1.1.0): Loading from cache
  - Installing symfony/serializer (v4.1.10): Loading from cache
  - Installing friendsofsymfony/jsrouting-bundle (2.2.2): Loading from cache
  - Installing sensio/framework-extra-bundle (v5.2.4): Loading from cache
  - Installing symfony/apache-pack (v1.0.1): Loading from cache
  - Installing symfony/dotenv (v4.1.10): Loading from cache
  - Installing symfony/expression-language (v4.1.10): Loading from cache
  - Installing symfony/inflector (v4.1.10): Loading from cache
  - Installing symfony/property-access (v4.1.10): Loading from cache
  - Installing symfony/options-resolver (v4.1.10): Loading from cache
  - Installing symfony/intl (v4.1.10): Loading from cache
  - Installing symfony/polyfill-intl-icu (v1.10.0): Loading from cache
  - Installing symfony/form (v4.1.10): Loading from cache
  - Installing monolog/monolog (1.24.0): Loading from cache
  - Installing symfony/monolog-bridge (v4.1.10): Loading from cache
  - Installing symfony/monolog-bundle (v3.3.1): Loading from cache
  - Installing doctrine/orm (v2.6.3): Loading from cache
  - Installing doctrine/doctrine-migrations-bundle (v2.0.0): Loading from cache
  - Installing symfony/orm-pack (v1.0.6): Loading from cache
  - Installing symfony/security (v4.1.10): Loading from cache
  - Installing symfony/security-bundle (v4.1.10): Loading from cache
  - Installing symfony/property-info (v4.1.10): Loading from cache
  - Installing symfony/serializer-pack (v1.0.2): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.1.3): Loading from cache
  - Installing symfony/swiftmailer-bundle (v3.2.5): Loading from cache
  - Installing twig/twig (v2.6.2): Loading from cache
  - Installing symfony/twig-bridge (v4.1.10): Loading from cache
  - Installing symfony/twig-bundle (v4.1.10): Loading from cache
  - Installing symfony/translation (v4.1.10): Loading from cache
  - Installing symfony/validator (v4.1.10): Loading from cache
  - Installing psr/link (1.0.0): Loading from cache
  - Installing fig/link-util (1.0.0): Loading from cache
  - Installing symfony/web-link (v4.1.10): Loading from cache
  - Installing symfony/asset (v4.1.10): Loading from cache
  - Installing symfony/webpack-encore-pack (v1.0.3): Loading from cache
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".
!!  Did you forget a "use" statement for another namespace? in /var/www/symepty/src/Kernel.php:33
!!  Stack trace:
!!  #0 /var/www/symepty/vendor/symfony/http-kernel/Kernel.php(405): App\Kernel->registerBundles()
!!  #1 /var/www/symepty/vendor/symfony/http-kernel/Kernel.php(120): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!!  #2 /var/www/symepty/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Component\HttpKernel\Kernel->boot()
!!  #3 /var/www/symepty/vendor/symfony/console/Application.php(145): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!!  #4 /var/www/symepty/bin/console(39): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
!!  #5 {main}
!!    thrown in /var/www/symepty/src/Kernel.php on line 33
!!  
Script @auto-scripts was called via post-install-cmd

检查在prod环境中激活了哪些捆绑包

请参阅:
config/bundles.php
文件

你应该看到:

return [
...
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
...
]
这真是太愚蠢了x)我只是忘了将.ENV文件中的
APP_ENV
var设置为'prod':

APP_ENV=dev
APP_ENV=prod

并在composer安装之前清除缓存和供应商:
rm-rf供应商和&var/cache
尝试运行

SYMFONY_ENV=PROD bin/console doctrine:migrations:migrate

查看config/bundles.php并验证WebProfilerBundle没有['all'=>true]。如果安装不正确,可能会发生这种情况。请向我们展示
/var/www/myapp/src/Kernel.php:33
?谢谢您的帮助!不幸的是,我在
config/bundles.php
文件中有
Symfony\Bundle\WebServerBundle\WebServerBundle::class=>['dev'=>true],
(我没有test=>true,但我们不在乎否?)