In Getting going with Heroku and PHP (part 1) I detailed how I start using “git subtree” to push my “build” folder into a separate repo, which Heroku would then automatically deploy.
However, Heroku wasn’t happy that it was having to make so many assumptions, so my next step was to try and be more explicit.
My first step was the take the composer.json file from the Github repo and modify that. The version I grabbed looked like this…
{
"require" : {
"silex/silex": "^2.0.4",
"monolog/monolog": "^1.22",
"twig/twig": "^2.0",
"symfony/twig-bridge": "^3"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
However, I don’t have any of those requirements, so I removed them. This got me slightly further forward, but Heroku was now saying that it didn’t have a composer.lock file. It was getting increasingly obvious that I was going to actually need to install Composer, so I went off and did this. However, this wouldn’t install without installing PHP, so I went and installed this as well. Then I could point Composer at PHP and everything went on fine.
Now I could generate a new “composer.lock” file from my “composer.json” file by running…
composer update
Sidebar: It was at this point in my life that I discovered that whenever I type the word “composer” I actually type “computer”, and then have to go back and correct it. Weird.
Heroku was now happy that I had a proper “composer.lock” file, but was still default installing PHP 5.5, and I wanted the latest PHP 7.2. So I added a new requirement, and my file looked like this…
{
"require" : {
"php": ">=7.2.0"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
Then I re-generated my “composer.lock” file, pushed my “build” folder to Heroku once more and it worked!
Having said that, it was still defaulting to Apache, which is fine, but it was moaning that I hadn’t specified it. So I went back to Github and grabbed the Procfile which looked like this…
web: vendor/bin/heroku-php-apache2 web/
All of this is of course explained in the tutorial, I just skipped ahead!
Unfortunately, this completely broken everything. Heroku was happy that everything was building and deploying ok, but I was getting Server 503 errors instead of seeing my website, so something was wrong!
Check out what happened next in the third and final installment of this blog series, coming to a browser (or possibly RSS reader) near you soon.