【发布时间】:2021-03-06 10:33:04
【问题描述】:
我有一个 PHP 应用程序,可以在我的本地计算机和 Heroku 上正常运行。它连接到 Heroku 的 Github 存储库,我正在努力部署一个分支。
每当我点击“部署分支”时,我都会收到以下错误消息。
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/php.tgz
! ERROR: Application not supported by this buildpack!
!
! The 'heroku/php' buildpack is set on this application, but was
! unable to detect a PHP codebase.
!
! A PHP app on Heroku requires a 'composer.json' at the root of
! the directory structure, or an 'index.php' for legacy behavior.
!
! If you are trying to deploy a PHP application, ensure that one
! of these files is present at the top level directory.
!
! If you are trying to deploy an application written in another
! language, you need to change the list of buildpacks set on your
! Heroku app using the 'heroku buildpacks' command.
!
! For more information, refer to the following documentation:
! https://devcenter.heroku.com/articles/buildpacks
! https://devcenter.heroku.com/articles/php-support#activation
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
我已阅读错误消息,并且我同时拥有 composer.json 和 index.php 文件。以下是我的应用程序的结构:
my_project:
- vendor/
- .gitignore
- .env
- composer.json
- composer.lock
- index.php
- Procfile
我有什么遗漏吗?
【问题讨论】:
-
根文件夹中有 composer.json 还是它们位于子文件夹中(如“my_project”)?错误消息说:“Heroku 上的 PHP 应用程序在目录结构的根目录中需要一个 'composer.json'”
-
"my_project" 是所有文件所在的根文件夹。
-
您是否也在上传文件夹
my_project?如果是,则仅上传内容,而不是文件夹,因为这会将您的代码放入子文件夹 (my_project) 而不是根目录(my_project文件夹所在的位置)。 -
我的主目录中有一个名为
Web Projects的目录。这是我保存所有项目的地方。现在,我为我目前正在进行的项目创建了一个新目录my_project。因此,my_project是该项目的根目录/文件夹,其中初始化了 git 并保留了所有文件。我从这个目录中推送到 Heroku。