How to deploy a Laravel application on Heroku
A couple of days ago, I needed to deploy a laravel application on Heroku. Heroku is a platform as a service (PaaS) that enables developers to build and run applications entirely in the cloud. It is very popular, indeed. "It won't be difficult", I thought. However, as always, it has its tricks and workarounds. Keep reading if you want to save yourself some time.
Disclaimer: The application I will deploy does not use a database.
cdinto your application folder. Your application folder must be a git respository. If it is not, run:
git init .
3. We then need to tell Heroku to look for our application within the
/publicdirectory since the default apache2 process points to the web root. To achieve this, go ahead and create a custom configuration file called
Procfile. Beware of capitalization. Within this file, write down this line:
web: vendor/bin/heroku-php-apache2 public
4. Since you have installed the Heroku toolbelt, you have now new commands to play with. We first need to create our application. Run:
heroku apps:create your-app-name
After this command, you will see this output:
Creating your-app-name... done, stack is cedar-14
https://your-app-name.herokuapp.com/ | https://git.heroku.com/your-app-name.git
Git remote heroku added
And the last line tell us that a new romote has been added to our repository. If you run:
git config -l, you should be able to see it:
5. We need to tell Heroku that our application is an PHP application. Otherwise, Heroku will try to guess out our application stack. It happened to me that since there was a package.json file in the project, Heroku thought my application was an nodejs application. To let Heroku Know our application is an PHP application, we need to run:
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
6. Deploy your application:
git push heroku master
7. Check it out:
Lo que dicen nuestros clientes
Got a incredible work from LebenLabs. A bunch of guys you can surely trust.
Obtuve un resultado increíble con LebenLabs. Un equipo realmente confiable.David Sturgeon