takanori-matsushita / laravel-practice

http://laraveltutorial.herokuapp.com/
0 stars 0 forks source link

herokuへデプロイ #13

Open takanori-matsushita opened 4 years ago

takanori-matsushita commented 4 years ago

微修正はmaster

takanori-matsushita commented 4 years ago

Procfileの作成 Laravelのプロジェクトルートディレクトリに配置する

Procfile

web: vendor/bin/heroku-php-apache2 public/
takanori-matsushita commented 4 years ago

heroku作成 ターミナルで以下のコマンドを入力(heroku CLI導入後) heroku create laraveltutorial --buildpack heroku/php

takanori-matsushita commented 4 years ago

APP_KEYの作成 heroku config:set APP_KEY=$(php artisan --no-ansi key:generate --show)

takanori-matsushita commented 4 years ago

herokuへpushする git push heroku master

takanori-matsushita commented 4 years ago

herokuへデプロイしたページを開く heroku open

takanori-matsushita commented 4 years ago

デバッグモードを有効にする heroku config:set APP_DEBUG=true

takanori-matsushita commented 4 years ago

データベースの設定 heroku上でPostgreSQLのアドオンを追加する dashbord->app名->Resources->Add-onsでHroku postgresを検索して追加

takanori-matsushita commented 4 years ago

本番環境上でのエラー

Attribute [auth] does not exist. laravel/uiのミドルウェアのauthが見つからないと怒られる。 対処方法 composerのrequire-devにインストールしていたので、本番環境にインストールし直す。 composer require laravel/ui

Class 'Faker\Factory' not found クラスが見つからないと怒られる。 対処方法 Fakerは本番環境には必要ないが、今回は学習上シーディングを行いたいので、これも同様に本番環境にインストールし直す。 composer require fzaninotto/faker

takanori-matsushita commented 4 years ago

その他.envで設定した環境変数を設定する。 herokuで環境変数を設定するコマンド heroku config:set 環境変数名=値