1

I want to run a simple 'Hello World' PHP script to start understanding how Heroku functions in general. So I have created a git repository at Github with a simple 'Hello World' php script and an empty README file. Therefore the source code in the php file is:

<?php

echo 'Hello World';

?>

I applied step-by-step the instructions at Heroku:

  1. I downloaded the Heroku CLI
  2. entered heroku login and my credentials at the command line
  3. had php, composer and git installed
  4. entered git clone *my_git_repository_adress*
  5. entered cd *my_git_repository_name*
  6. entered heroku create

However, when I enter git push heroku master at the command line I get the following error: App not compatible with buildpack: https://github.com/heroku/heroku-buildpack-php.git.

Then when I try to set the buildpack by entering heroku buildpacks:set heroku/php, I get the following error:

 ▸    Missing required flag:
 ▸    -a, --app APP  app to run command against
 ▸    See more help with --help

What am I doing wrong?

Outcast
  • 4,967
  • 5
  • 44
  • 99

2 Answers2

0

You need to tell to Heroku that it's a PHP project. So run into your folder:

$ echo '{}' > composer.json
$ git add composer.json
$ git commit -m "add composer.json for PHP app detection"

or you can set your buildpacks manually:

$ heroku buildpacks:set heroku/php

And push again. Hope I help!

Junior Gantin
  • 2,102
  • 1
  • 18
  • 24
  • Thank you for your response. See my edited post above. I have tried to do this and I get an error. – Outcast Mar 12 '18 at 09:30
0

Heroku needs index.php to detect the buildpack. It seems you are just using single Hello World.php.

Try renaming the file or create an index.php and add redirect to your desired page.

Thamilhan
  • 13,040
  • 5
  • 37
  • 59
  • Thank you for your response. To start with, you are probably right about naming the php script as index.php but I think that it also requires to add other files like composer.json (github.com/heroku/php-getting-started). – Outcast Mar 12 '18 at 09:12
  • Secondly, can you be a bit more clear about what do you mean as my desired webpage? I thought that my 'Hello World' app will be hosted and presented in Heroku so I do not have to redirect it at any page... – Outcast Mar 12 '18 at 09:12
  • Regarding your first comment - Since you have mentioned - _#3 had php, composer and git installed_ thought that you have `composer.json` already – Thamilhan Mar 12 '18 at 12:52
  • _desired page_ - Something like `Hello World.php`. BTW - I haven't mentioned _desired webpage_ – Thamilhan Mar 12 '18 at 12:53
  • Ok finally it run even though I did not have a composer.json in my git (however I got a warning about it). I am going to write how I did in detail later. Ok sorry about the webpage but when you are using the term page I am instantly reading it as webpage. – Outcast Mar 13 '18 at 09:25