Home » Php » html – Deploy PHP to Heroku

html – Deploy PHP to Heroku

Posted by: admin April 23, 2020 Leave a comment

Questions:

Since Heroku began Facebook integration awhile ago, I’ve wanted to deploy a few PHP files without having to use Facebook and just viewing my PHP on Heroku. This link here, Deploying WordPress to Heroku simply states you can. But, I can’t seem to figure out the PHP portion. I have a Rack app already built and tried some implementation that would just view PHP instead of HTML, and that didn’t work. All it did is display static text. The same with just having a PHP file on the app in the /public folder, just displays static text. This has to work somehow since the link I shared works you through the process of getting WordPress on Heroku. If anyone could, tell me how to get a few PHP files running on my Heroku app, I’d really appreciate it.

Thanks

How to&Answers:

You don’t need to do anything – just push your PHP code up and Heroku magic will occur – I’m no PHP guru but recently had to deploy a PHP site and I just pushed the code as is to a new Cedar app, no changing of directory structures etc and it works.

Answer:

You need to create your Heroku app on the new Cedar stack. Cedar stack apps reside on the domain herokuapp.com rather than heroku.com, so you’ll know if you’ve got the right one. Then it’s really as simple as pushing your PHP files. To create an app on the Cedar stack, use:

heroku create

Or, if you’d like to set a name, (i.e. myname.herokuapp.com) use:

heroku create myapp

For the benefit of others who are not as au fait with Git, you will also need to set up, commit and push your Git repository:

git init
git add .
git commit -m 'Initial commit'
git push heroku master

That’s it! Good luck and have fun.

Answer:

Heroku now has a guide for deploying PHP, Getting Started with PHP on Heroku, which explains that Heroku depends on Composer.