Home > Software engineering >  How do I deploy plain PHP site (no framework used)
How do I deploy plain PHP site (no framework used)

Time:02-13

Wrote a tiny project containing about 5 files with vanilla PHP and Js. This means I have no composer.json & no .htaccess files, no database. Just a POST request to a script(php).

Tried deploying on Heroku but couldn't. Got the error below

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/php
-----> 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

CodePudding user response:

As the error message says, you must have a composer.json¹ in the root of your project.

If you don't have any dependencies, it can be empty:

{}

Add that file, commit it, and redeploy.


¹Or an index.php for "legacy behaviour", but who wants that?

  • Related