在开发环境中运行命令composer install
时,我没有任何问题。我想将我的symfony应用程序部署在另一台服务器(产品服务器)上,但是,当我运行命令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/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
我的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
答案 0 :(得分:0)
检查在产品环境中激活了哪些捆绑软件。
请参阅:config/bundles.php
文件
,您应该会看到以下内容:
return [
...
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
...
]
答案 1 :(得分:0)
那真是愚蠢x)我只是忘记将.env文件中的APP_ENV
var设置为'prod':
APP_ENV=dev
至
APP_ENV=prod
在安装作曲家之前清除缓存和供应商:rm -rf vendor && var/cache
答案 2 :(得分:0)
尝试运行
SYMFONY_ENV=PROD bin/console doctrine:migrations:migrate