我们有一个托管在 Heroku 上的 Symfony 4.3 Web 应用程序。这是一个新的设置我们从未设法让开发模式正常工作。网上有很多类似的问题,但没有一个能解决我们在这里面临的确切症状。
该项目是使用命令行创建的:
composer create-project symfony/website-skeleton appName
让我澄清一下:我们不想 change from "dev" to "prod"
我们需要能够在开发模式下使用该应用程序,以便根据以下内容利用 PHP 的错误调试Symfony 4.3 的文章“如何自定义错误页面”在这里
$ php bin/console about
-------------------- ----------------------------------------------------
Symfony
-------------------- ----------------------------------------------------
Version 4.3.5
End of maintenance 01/2020
End of life 07/2020
-------------------- ----------------------------------------------------
Kernel
-------------------- ----------------------------------------------------
Type App\Kernel
Environment dev
Debug true
Charset UTF-8
Cache directory ./var/cache/dev (12.1 MiB)
Log directory ./var/log (13 KiB)
-------------------- ----------------------------------------------------
PHP
-------------------- ----------------------------------------------------
Version 7.3.10
Architecture 64 bits
Intl locale n/a
Timezone Europe/Berlin (2019-10-28T15:48:05+01:00)
OPcache false
APCu false
Xdebug false
-------------------- ----------------------------------------------------
Environment (.env)
-------------------- ----------------------------------------------------
APP_ENV dev
*just a few removed before posting for privacy*
-------------------- ----------------------------------------------------
如果我们从“dev”环境更改为“prod”环境,应用程序可以工作,但我们无法按照我们希望的方式看到错误。我们可以使用下面的命令(但这不是我们在这里要解决的问题)来使用“Symfony Var Dumper Server”。我们不想使用这种方法。
./bin/console server:dump
看来我们可能缺少一个依赖项,但是composer update
and composer install
and composer dump-autoload
没有解决任何问题。
另请注意消息“您是否忘记了另一个命名空间的“use”语句?在/tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/src/Kernel.php:23“ - 主存储库中的 WebProfilerBundle 是否可能已损坏?
为了进一步帮助大家了解情况,现将情况说明如下:composer.json
file
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"phpmailer/phpmailer": "^6.1",
"sensio/framework-extra-bundle": "^5.5",
"symfony/asset": "4.3.*",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
"symfony/expression-language": "4.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "4.3.*",
"symfony/framework-bundle": "4.3.*",
"symfony/http-client": "4.3.*",
"symfony/intl": "4.3.*",
"symfony/mailer": "4.3.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "^1.0",
"symfony/process": "4.3.*",
"symfony/security-bundle": "4.3.*",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/translation": "4.3.*",
"symfony/twig-bundle": "4.3.*",
"symfony/twig-pack": "^1.0",
"symfony/validator": "4.3.*",
"symfony/web-link": "4.3.*",
"symfony/webpack-encore-bundle": "^1.7",
"symfony/yaml": "4.3.*"
},
"require-dev": {
"symfony/debug-bundle": "4.3.*",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.14",
"symfony/profiler-pack": "^1.0",
"symfony/test-pack": "*",
"symfony/web-profiler-bundle": "4.3.*",
"symfony/web-server-bundle": "4.3.*"
},
"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.3.*"
}
}
}
我们的障碍:尝试使用部署到herokudev
mode.
git push heroku master
失败并显示以下消息:
remote: Executing script cache:clear [KO]
remote: [KO]
remote: Script cache:clear returned with error code 255
remote: !! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".
remote: !! Did you forget a "use" statement for another namespace? in /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/src/Kernel.php:23
remote: !! Stack trace:
remote: !! #0 /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/vendor/symfony/http-kernel/Kernel.php(429): App\Kernel->registerBundles()
remote: !! #1 /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/vendor/symfony/http-kernel/Kernel.php(130): Symfony\Component\HttpKernel\Kernel->initializeBundles()
remote: !! #2 /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/vendor/symfony/framework-bundle/Console/Application.php(159): Symfony\Component\HttpKernel\Kernel->boot()
remote: !! #3 /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
remote: !! #4 /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/vendor/symfony/console/Application.php(149): Symfony\Bundle\FrameworkBundle\Cons in /tmp/build_a45354eb0ee7b20dd7ec870ed4fb1980/src/Kernel.php
on line 23
remote: !!
remote: Script @auto-scripts was called via post-install-cmd
remote: ! WARNING: There was a class not found error in your code
remote:
remote: ! ERROR: Dependency installation failed!
remote: !
remote: ! The 'composer install' process failed with an error. The cause
remote: ! may be the download or installation of packages, or a pre- or
remote: ! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote: ! in your 'composer.json'.
remote: !
remote: ! Typical error cases are out-of-date or missing parts of code,
remote: ! timeouts when making external connections, or memory limits.
remote: !
remote: ! Check the above error output closely to determine the cause of
remote: ! the problem, ensure the code you're pushing is functioning
remote: ! properly, and that all local changes are committed correctly.
remote: !
remote: ! For more information on builds for PHP on Heroku, refer to
remote: ! https://devcenter.heroku.com/articles/php-support
remote: !
remote: ! REMINDER: the following warnings were emitted during the build;
remote: ! check the details above, as they may be related to this error:
remote: ! - There was a class not found error in your code
remote:
remote: ! Push rejected, failed to compile PHP app.
remote:
remote: ! Push failed
我们目前不知道如何安装或验证捆绑包确实存在并且可用于 Symfony 4.3 - 这个方向的想法可能会有所帮助,但不仅仅是。
php bin/console config:dump-reference
Available registered bundles with their extension alias if available
====================================================================
---------------------------- ------------------------
Bundle name Extension alias
---------------------------- ------------------------
DebugBundle debug
DoctrineBundle doctrine
DoctrineCacheBundle doctrine_cache
DoctrineMigrationsBundle doctrine_migrations
FrameworkBundle framework
MakerBundle maker
MonologBundle monolog
SecurityBundle security
SensioFrameworkExtraBundle sensio_framework_extra
SwiftmailerBundle swiftmailer
TwigBundle twig
TwigExtraBundle twig_extra
WebProfilerBundle web_profiler
WebServerBundle web_server
WebpackEncoreBundle webpack_encore
---------------------------- ------------------------
// Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g.
// config:dump-reference FrameworkBundle)
//
// For dumping a specific option, add its path as the second argument of this command. (e.g.
// config:dump-reference FrameworkBundle profiler.matcher to dump the
// framework.profiler.matcher configuration)