LoginSignup
2
1

More than 3 years have passed since last update.

Herokuでphpをデプロイしようとしたときにfailed to pushされた話

Posted at

はじめに

同じことをやって時間を消費したりしないようにメモ。
届け、ろくに公式を読んでない人へ

ここの手順通りやったぞ! という方は本記事の対象外です。
(https://devcenter.heroku.com/articles/getting-started-with-php)

オチ

わけのわからんググり方をする前に、ちゃんと公式のdocsを読もう!

やりたかったこと

とにかく簡易APIをデプロイしたい

<?php
  if ($_GET('golden') === 'tanigaki') {
    echo 'ムッワァァァ';
  } else {
    echo 'kamuy';
  }
?> 

起きた問題

heroku create

したあとに

git push heroku master

したら、

! [ remote/reject ] master -> master (pre-receive hook declined)
error : failed to push some refs to 'https://git.heroku.com/アプリ名.git'

と表示されてpushできない

対処方法

これはphpをデプロイしようとしているのに composer が入ってないことが原因。
とりあえず空でもいいから、composer.json を作ってつっこむべし。
で、 heroku君には composer使うで! って教えてあげよう

$ echo '{}' > composer.json
$ git add composer.json
$ git commit -m "add composer.json for PHP app detection"
$ heroku buildpacks:set heroku/php

ここまでできたら、満を持して
git push heroku master

してください。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1