OVH服务器上的symfony 4.3,缓存清除返回错误255(当composer更新/heroku从github部署时



我做了一个symfony 4.3应用程序,想把它放在我的OVH服务器上。我在github上保存了我的应用程序,并忽略了.env文件,加上.gitignore中已经忽略的所有文件和文件夹。然后,在SSH中,在我的OVH服务器中,我做了一个git克隆来获取我的应用。然后我做了composer更新,以获取所有丢失的文件和文件夹(var、vendor、.env)。这给了我错误:

Executing script cache:clear [KO]
[KO]
script cache:clear returned with error 255
!!
script @auto-scripts was called via post-update-cmd

我的服务器上有供应商,但既没有var也没有.env。所以我通过filezilla在FTP中手动传输.env,我用APP_env=prod更改了它,然后我手动(仍然使用filezilla)创建了一个var文件夹,里面有缓存和日志文件夹(我没有传输我的,所以它是空的,所以已经清除了)。然后我检查了一下:我的网站是在互联网上运行的(从我的服务器上,而不是在本地)。

那么,问题解决了吗。。。是的和不是。这个网站是有效的,但我的目的不是在互联网上发布一个网站,而是学习(我在udemy上上上了一堂符号课)。我学会了如何使用heroku进行自动部署。

所以我创建了一个heroku帐户,将其链接到我的github帐户和我的应用程序。但是,当我尝试从heroku手动部署时(在自动部署之前检查它是否有效),我仍然有一个缓存清除255错误([修改:一些数字和字母]是我隐藏在错误消息中的东西,因为我想知道这是否敏感):

Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!  PHP Fatal error:  Uncaught SymfonyComponentDotenvExceptionPathException: Unable to read the "/tmp/build_[modified : some numbers and letters]/.env" environment file. in /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php:484
!!  Stack trace:
!!  #0 /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php(65): SymfonyComponentDotenvDotenv->doLoad(false, Array)
!!  #1 /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php(85): SymfonyComponentDotenvDotenv->load('/tmp/build_a7cc...')
!!  #2 /tmp/build_[modified : some numbers and letters]/config/bootstrap.php(15): SymfonyComponentDotenvDotenv->loadEnv('/tmp/build_a7cc...')
!!  #3 /tmp/build_[modified : some numbers and letters]/bin/console(30): require('/tmp/build_a7cc...')
!!  #4 {main}
!!    thrown in /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php on line 484
!!  
Script @auto-scripts was called via post-install-cmd
!     ERROR: Dependency installation failed!
!     
!     The 'composer install' process failed with an error. The cause
!     may be the download or installation of packages, or a pre- or
!     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
!     in your 'composer.json'.
!     
!     Typical error cases are out-of-date or missing parts of code,
!     timeouts when making external connections, or memory limits.
!     
!     Check the above error output closely to determine the cause of
!     the problem, ensure the code you're pushing is functioning
!     properly, and that all local changes are committed correctly.
!     
!     For more information on builds for PHP on Heroku, refer to
!     https://devcenter.heroku.com/articles/php-support
!     Push rejected, failed to compile PHP app.
!     Push failed

由于出现错误消息,我查看了我的composer.json文件,得到的是:

"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},

它有什么毛病吗?我看不出我能在里面改变什么。

我尝试了很多我在网上找到的东西:

https://github.com/symfony/flex/issues/406composer更新symfony/flex——没有插件——没有脚本。composer安装

在ssh中执行本身没有产生任何错误,但在再次尝试在heroku 上部署时没有解决问题

在这种情况下,我也尝试了老师在课堂上提出的建议:

composer config disable-tls true
composer install

相同:这样做时没有错误,但在尝试部署在heroku 上时没有解决问题

从昨天开始的很多事情,我都不记得我试过的每一件事了://但都没用。

确保在Heroku中设置了环境变量SYMFONY_ENV=prod,在.ENV文件中设置了APP_ENV=prod。

最新更新