我正在使用Webpack开发Symfony 4.2中的一个项目。我正在使用BitBucket对代码进行版本控制,并且正在使用heroku进行部署。该应用程序在我本地计算机上的开发环境中运行良好。但是我在Heroku的生产模式下出现错误。服务器找不到文件manifest.json,我的资产文件生成404错误。
这是我的assets.yaml配置文件的内容:
framework:
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
以下是我的错误:
2019-01-23T14:17:36.377047+00:00 app[web.1]: [2019-01-23 14:17:36] request.INFO: Matched route "app_login". {"route":"app_login","route_parameters":{"_route":"app_login","
_controller":"App\\Controller\\SecurityController::login"},"request_uri":"http://**********.herokuapp.com/","method":"GET"} []
2019-01-23T14:17:36.377226+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1
} []
2019-01-23T14:17:36.377448+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\\Se
curity\\LoginFormAuthenticator"} []
2019-01-23T14:17:36.377787+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"main","authenticator"
:"App\\Security\\LoginFormAuthenticator"} []
2019-01-23T14:17:36.379214+00:00 app[web.1]: [2019-01-23 14:17:36] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
**2019-01-23T14:17:36.379828+00:00 app[web.1]: [2019-01-23 14:17:36] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the re
ndering of a template ("Asset manifest file "/app/public/build/manifest.json" does not exist.")." at /tmp/build_6b468a926db1e3ce965958cbead3b64f/templates/base.html.twig l
ine 8 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Asset manifest file \"/app/public/build/manif
est.json\" does not exist.\"). at /tmp/build_6b468a926db1e3ce965958cbead3b64f/templates/base.html.twig:8, RuntimeException(code: 0): Asset manifest file \"/app/public/buil
d/manifest.json\" does not exist. at /app/vendor/symfony/asset/VersionStrategy/JsonManifestVersionStrategy.php:57)"} []
2019-01-23T14:17:36.380146+00:00 app[web.1]: 10.92.136.3 - - [23/Jan/2019:14:17:36 +0000] "GET / HTTP/1.1" 500 918 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebK
it/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36**
我还尝试禁用对assets.yaml配置文件中的manifest.json文件的访问。而且我的资产文件出现404错误:
2019-01-23T15:45:20.646929+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:20 +0000] "GET / HTTP/1.1" 200 3878 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleW
ebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.821244+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:20 +0000] "GET /build/app.css HTTP/1.1" 404 211 "https://***********.herokuapp.com/" "M
ozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.830189+00:00 app[web.1]: 10.13.65.189 - - [23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/tether/dist/js/tether.min.js HTTP/1.1" 404 244 "https://
caisse-fitfit.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.962711+00:00 app[web.1]: 10.10.240.248 - -
[23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/underscore/underscore-min.js HTTP/1.1" 404 244 "https:/
/*************.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.976373+00:00 app[web.1]: 10.13.65.189 - -
[23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/jQuery-Storage-API/jquery.storageapi.min.js HTTP/1.1" 40
4 259 "https://*********.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.001653+00:00 app[web.1]: 10.37.18.194 - - [23/Jan/2019:15:45:21 +0000] "GET /build/libs/jquery/PACE/pace.min.js HTTP/1.1" 404 232 "https://caisse-fitfi
t.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.111050+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/config.lazyload.js HTTP/1.1" 404 230 "https://************
.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.121765+00:00 app[web.1]: 10.13.65.189 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/palette.js HTTP/1.1" 404 222 "https://***********.herokuap
p.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.153872+00:00 app[web.1]: 10.37.18.194 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/ui-load.js HTTP/1.1" 404 222 "https://caisse-fitfit.herokuap
p.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.160011+00:00 app[web.1]: 10.10.240.248 - -
我测试了网上找到的几种解决方案,但没有一个可行。 :(
答案 0 :(得分:0)
这也发生在我身上,在git克隆了我一直在(不同计算机上)工作过的仓库之后。 Symfony4项目。 我运行过yarn的安装和composer的安装,然后设置了db,然后发生了清单文件错误。 经过一番研究后,我解决该问题的方法:运行Encore来构建资产:-)
希望有帮助
答案 1 :(得分:0)
最后,我解决了这个问题。 问题是gitignore文件。 我的文件配置不正确。 我将这些行添加到gitignore文件中:
###> symfony/webpack-encore-bundle ###
/node_modules/
!/public/build/
!/public/build/*
npm-debug.log
yarn-error.log
现在就可以使用