LoginSignup
11
10

More than 5 years have passed since last update.

HerokuでPHPを利用するときにハマったことのメモ

Last updated at Posted at 2015-07-10

メール送信

アドオン契約が必要
アドオンにてsendGridやmailGunなどを利用する。

MySQLを利用する

アドオン契約が必要
ドキュメントルート以下にprocfileを作成
ファイル名Procfileで内容は
web: vendor/bin/heroku-php-apache2 public
こんな感じ
heroku configでデータベース接続情報を取得し、
phpのdb接続設定やmysqlコマンドの接続情報に利用する

mb_convert_encodingが使えない

composer.jsonに次を記載

javascript
{
  "require": {
    "ext-mbstring": "*"
  }
}

インデントは半角スペースでタブを使うとverifyエラーとなる。

date関数を利用する際の注意

デフォルトタイムゾーンを指定する。

php
date_default_timezone_set("Asia/Tokyo");

push時にcomposerエラー

remote: ! ERROR: Your 'composer.json' lists dependencies inside 'require',
remote: but no 'composer.lock' was found. Please run 'composer update' t
remote: re-generate 'composer.lock' if necessary, and commit it into you
remote: repository. For more information, please refer to the docs at
remote: https://devcenter.heroku.com/articles/php-support#activation

対策
php composer.phar update

これでできたcomposer.lockファイルをaddしてcommitして再度push
remote: Verifying deploy.... done.

vender/ ディレクトリはaddする必要は無い

11
10
1

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
11
10