-
https://mattstauffer.co/blog/laravel-on-heroku-using-a-postgresql-database
-
https://devcenter.heroku.com/articles/getting-started-with-php#deploy-the-app
laravel new hello-heroku
cd hello-heroku
heroku login
heroku create
web: vendor/bin/heroku-php-apache2 public/
heroku ps
heroku ps:scale web=1
rm package.json gulpfile.js
I don't like to mixup langages. But if you do, you should set buildpack for Heroku to use PHP or else it will use node.js because of the package.json
file. To set the buildpack use:
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php
cp .env.example .env
heroku config:set APP_KEY=RandomStringKey! (Use php artisan key:generate to get one)`
Heroku needs log to be sent to stderr. To do this set the env variable.
heroku config:set APP_LOG=errorlog
https://devcenter.heroku.com/articles/php-sessions
https://mattstauffer.co/blog/laravel-on-heroku-using-a-postgresql-database
heroku addons:create heroku-postgresql:hobby-dev
# file config/database.php
<?php
$heroku_db_url = parse_url(env('DATABASE_URL', "postgres://forge:forge@localhost:5432/forge"));
.
.
.
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path('database.sqlite'),
'prefix' => '',
],
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
'pg-heroku' => [
'driver' => 'pgsql',
'host' => $heroku_db_url['host'],
'database' => substr($heroku_db_url['path'], 1),
'username' => $heroku_db_url['user'],
'password' => $heroku_db_url['pass'],
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
.
.
.
heroku config:set DB_CONNECTION=pg-heroku
heroku run php artisan migrate
thanks!