Symfony 4,迁移到生产,命令“composer install --no-dev”失败(ClassNotFoundException:WebProfilerBundle)

En dev environment when I run the command composer install I haven't any problem. I want to deploy my symfony app in an another server (a prod server), however, when I run the command composer install --no-dev I get an error and I don't find/understand what is the problem.

The logs are :

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/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/myapp/src/Kernel.php:33
!!  Stack trace:
!!  #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/framework-bundle/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(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!!  #4 /var/www/myapp/bin/console(39): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
!!  #5 {main}
!!    thrown in /var/www/myapp/src/Kernel.php on line 33
!!  
Script @auto-scripts was called via 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.*"
        }
    }
}

Thanks for any help/tips ! I'm not a great composer user :/

Edit, the complete output of the command 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
dongmi4734
dongmi4734 你能告诉我们/var/www/myapp/src/Kernel.php:33吗?
一年多之前 回复
doubi8512
doubi8512 查看config/bundles.php并验证WebProfilerBundle没有['all'=>true]。如果安装不正确,可能会发生这种情况。
一年多之前 回复

3个回答



检查在prod环境中激活了哪些包。</ p>

请参阅: config / bundles .php </ code>文件</ p>

您应该看到一些:</ p>

  return [
...
Symfony \ Bundle \ WebProfilerBundle \ WebProfilerBundle :: class =&gt; ['dev'=&gt; 是的,'test'=&gt; 是],
...
]
</ code> </ pre>
</ div>

展开原文

原文

Check what bundles are activated in prod environment.

see: config/bundles.php file

and you should see some as:

return [
...
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
...
]

duanlu9816
duanlu9816 谢谢你的帮助 ! 不幸的是,我在config / bundles.php文件中有Symfony \ Bundle \ WebServerBundle \ WebServerBundle :: class => ['dev'=> true](我没有test => true,但我们并不在乎 不?)
一年多之前 回复



这真的很愚蠢x)我忘了将.env文件中的 APP_ENV </ code> var设置为'prod ':</ p>

APP_ENV = dev </ code>
to
APP_ENV = prod </ code> </ p>

并清除 缓存和 在作曲家安装之前的供应商: rm -rf vendor&amp;&amp; var / cache </ code> </ p>
</ div>

展开原文

原文

It was really stupid x) I just forgot to set the APP_ENV var in .env file to 'prod' :

APP_ENV=dev to APP_ENV=prod

and clear caches & vendor before the composer install : rm -rf vendor && var/cache



尝试运行</ p>

  SYMFONY_ENV = PROD bin / console doctrine:migration:migrate

</ code> </ pre>
</ div>

展开原文

原文

Try to run

SYMFONY_ENV=PROD bin/console doctrine:migrations:migrate

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐