简体   繁体   中英

How to deploy Laravel 4 Apps on Heroku?

I know that Heroku supports many different environments in the Cedar stack including PHP .
The tipical folder structure of a Laravel 4 app is the following:

app/
bootstrap/
public/
    packages/
    index.php
vendor/
composer.json
phpunit.xml

Note 2 things:

  1. The main index.php file is not located in the root, is under the public folder.

  2. There is a composer.json file and Heroku needs to install all the project dependencies automatically just like gems in Ruby apps.

So my question is:
Is there a way to deploy this kind of apps on Heroku ??

Any help appreciated.

You'll need to use a custom buildpack to set the document root and executes a script that integrates composer too. In Heroku's Buidlpack you would need to update the bin/compile script to handle composer and conf/httpd.conf to set the document root. Also, Heroku's buildpack does not have mcrypt compiled in, so Laravel 4 won't work with that buildpack. I've included many updates that include mcrypt, composer, and custom document roots in my branch of the buildpack .

Heroku has recently released a official PHP buildpack https://github.com/heroku/heroku-buildpack-php . It's new and i had some initial troubles with it. but it should improve. It supports PHP or HHVM.

Its possible to specify your application's entry point in an Procfile, place it in in the root directory of your application. In your case the contents would be:

web: vendor/bin/heroku-php-apache2 public/

https://devcenter.heroku.com/articles/getting-started-with-php#define-a-procfile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM