Tuesday, March 7, 2017

[ANSWERED]Deploying laravel php app with pgsql on heroku

I am trying to deploy laravel php app on heroku,the app deployed perfectly without DB but when i try to add the postgresql addon in my application it doesnt show any error in the cmd and also i have a login and register page, both are also working prefectly,I am able to register and login without any problem.
But he problem is when i try to open any other pages that is connected to dB. it shows the error on my browser
"Whoops, looks like something went wrong."
I am not getting any other errors.i dont know what is happening. If somebody can help.thanks
The steps i adopted to deply are.
$ git init
$ git add .
$ git commit -m "new laravel project"


$echo web: vendor/bin/heroku-php-apache2 public/ > Procfile
$ git add .
$ git commit -m "Procfile for Heroku"

$heroku create

$ heroku config:set APP_KEY= key
$git push heroku master

now for the pgsql i did..
 $ heroku addons:add heroku-postgresql:hobby-dev

$ heroku config

Changed the value of 'default' in app/config/database.php to 'pgsql'.
'default' => 'pgsql',

At the top of database.php:
$url = parse_url(getenv("DATABASE_URL"));

$host = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$database = substr($url["path"], 1);

Then change your pgsql entry in that same file to be the following:
'pgsql' => array(
    'driver'   => 'pgsql',
    'host'     => $host,
    'database' => $database,
    'username' => $username,
    'password' => $password,
    'charset'  => 'utf8',
    'prefix'   => '',
    'schema'   => 'public',
),


$ git add .
$ git commit -m "Convert to use Heroku PostgreSQL database"
$ git push heroku master
$ heroku run php artisan migrate



via Hassan Haroon

Advertisement