• 3 mar

    2015

  • Leandro
    Masuero
    Technical Lead

  • Development

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.

  1. 1. The first thing you need to do, is sign up for Heroku account and install the heroku toolbelt, a command line toolkit to instruct Heroku what to do with your applications.

  2. 2. cd into your application folder. Your application folder must be a git respository. If it is not, run:

    git init .

  3. 3. We then need to tell Heroku to look for our application within the /public directory 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. 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:

    remote.heroku.url=https://git.heroku.com/your-app-name.git

  5. 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. 6. Deploy your application:

    git push heroku master

  7. 7. Check it out:

    heroku open

  8. 8. Enjoy!

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

Other blog posts

Laravel 5.0
  • 9 feb
    2015

Laravel 5.0 is out!

Here at LebenLabs, we embraced Laravel as our PHP framework to start new projects. From the begging, we have been very excited of Laravel evolution. Its growing community and its simplicity are the features we love most.

Continuar leyendo...