1

I have a rails application that uses php code. I am calling the php code directly with a system call 'php path/to/script.php'

This works fine on my local machine where I have php installed. I'm looking to deploy this to somewhere like Heroku. To solve this problem, I am using the multibuildpack Github library:

github.com/ddollar/heroku-buildpack-multi

I have specified in my .buildpacks

https://github.com/heroku/heroku-buildpack-php.git https://github.com/heroku/heroku-buildpack-ruby.git

and both install just fine. The problem is that Heroku treats the application like a php application. On the Heroku logs, it states that it is using the php configuration and is starting php-fpm when I want it to run as a rails application.

How do I go about fixing this? Specifically, how do I make sure that php is ready on Heroku when I make the system call

5
  • 1
    That might be a weird question but.. why do you mix two completely different languages like ruby and php? Can't you rewrite the script to ruby? Commented May 30, 2014 at 9:35
  • Its an existing library. I could rewrite the entire library in Ruby but that would take an incredibly long time considering there are 30+ files. Commented May 30, 2014 at 9:39
  • If there is library to do something in php then almost certainly there is its ruby equivalent and if not then it could be achieved some other way. Could you try to explain what exactly this library does? :) Commented May 30, 2014 at 9:41
  • Its the PHP routeboxer implementation on Github. github.com/bazo/route-boxer Although there are only 4 files there are dependencies that would need to be installed and translated as well. Commented May 30, 2014 at 9:43
  • I ended up deploying on a VPS to fix this problem. Commented May 30, 2014 at 22:21

3 Answers 3

1

You can do this by using multiple buildpacks

heroku buildpacks:add heroku/php --index 1 -a app-name

Also create a composer.json file on the root of your project, you can even specify the php version like this:

{
  "require": {
    "php": ">=5.4",
    "ext-mcrypt": ">=2.5.8"
  }
}

Finally create a composer.lock with

php composer.phar update --ignore-platform-reqs

Commit, deploy your code and all set.

Sign up to request clarification or add additional context in comments.

Comments

0

If PHP CLI is installed you could use the gem "php_process", which I wrote, to call the PHP library instead of bundling PHP files, which may be what is causing Heroku to define your project as using PHP.

https://github.com/kaspernj/php_process

2 Comments

Interesting.... so how would I go about calling a php script with this? And how can I get the return value of said PHP script? I'm using the library but I've also modified some functions in the library to suit my needs.
I could write examples on how to call various things with PhpProcess here on StackOverflow, but that stuff is already on the Github README of PhpProcess. But basically you would rewrite the script (not the library) to Ruby, but using the library through PhpProcess.
0

I don't believe there is a way to fix this because according to Heroku - they support both languages and determine which language is used in the application. It seems it's one language or the other.

I write PHP and have dabbled with Ruby on Heroku, but haven't tried mixing the two. It sounds a lot messier than I would be comfortable with, personally.

Why not try contacting Heroku Support?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.