如何在 Symfony4 中修复 "manifest file does not exist."
How to fix "manifest file does not exist." in Symfony4
我正在使用 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 - -
我测试了网上找到的几种解决方案,但 none 有效。 :(
这也发生在我身上,在 git 克隆了我一直在使用的存储库(不同的计算机)之后。 Symfony4 项目。
我安装了 运行 yarn install 和 composer install,然后设置了 db,然后出现了这个清单文件错误。
经过一些研究后,我修复它的方法是:运行 encore to build the assets :-)
我终于解决了这个问题。
问题是 gitignore 文件。
我的文件没有配置好。
我将这些行添加到 gitignore 文件中:
###> symfony/webpack-encore-bundle ###
/node_modules/
!/public/build/
!/public/build/*
npm-debug.log
yarn-error.log
现在可以使用了
我正在使用 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 - -
我测试了网上找到的几种解决方案,但 none 有效。 :(
这也发生在我身上,在 git 克隆了我一直在使用的存储库(不同的计算机)之后。 Symfony4 项目。 我安装了 运行 yarn install 和 composer install,然后设置了 db,然后出现了这个清单文件错误。 经过一些研究后,我修复它的方法是:运行 encore to build the assets :-)
我终于解决了这个问题。 问题是 gitignore 文件。 我的文件没有配置好。 我将这些行添加到 gitignore 文件中:
###> symfony/webpack-encore-bundle ###
/node_modules/
!/public/build/
!/public/build/*
npm-debug.log
yarn-error.log
现在可以使用了