vendredi 22 novembre 2019

Dependency installation failed! error while deploying laravel app to heroku

While trying to deploy a laravel app to Heroku, i started getting this Dependency installation failed! error after changing my DB_CONNECTION to Postgresql. When i do

git push heroku master

..........
remote:          - Installing jakub-onderka/php-console-color (v0.2): Loading from cache
remote:          - Installing nikic/php-parser (v4.3.0): Downloading (100%)
remote:          - Installing jakub-onderka/php-console-highlighter (v0.4): Loading from cache
remote:          - Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache
remote:          - Installing psy/psysh (v0.9.9): Loading from cache
remote:          - Installing laravel/tinker (v1.0.10): Loading from cache
remote:          - Installing guzzlehttp/guzzle (6.4.1): Downloading (100%)
remote:          - Installing unicodeveloper/laravel-paystack (1.0.2): Loading from cache
remote:        Package silex/silex is abandoned, you should avoid using it. Use symfony/flex instead.
remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:
remote:        In ConfigurationUrlParser.php line 132:
remote:
remote:          parse_url() expects parameter 1 to be string, array given
remote:
remote:
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
remote:  !     WARNING: A post-autoload-dump script terminated with an error
remote:
remote:  !     ERROR: Dependency installation failed!
remote:  !
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:  !
remote:  !     REMINDER: the following warnings were emitted during the build;
remote:  !     check the details above, as they may be related to this error:
remote:  !     - A post-autoload-dump script terminated with an error
remote:
remote:  !     Push rejected, failed to compile PHP app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to blemademo.
remote:
To https://git.heroku.com/blemademo.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/blemademo.git'

I have provisioned Heroku Postgres Hobby Dev as database on heroku dashboard and have DATABASE_URL set on my config. In my laravel database.php file i have this on top of the file;

$host = env('DB_HOST', '127.0.0.1');
$database = env('DB_DATABASE', '');
$username = env('DB_USERNAME', 'forge');
$password = env('DB_PASSWORD', 'forge');

if($databaseUrl = getenv('DATABASE_URL')) {
    $url = parse_url($databaseUrl);

    $host = $url['host'];
    $username = $url['user'];
    $password = $url['pass'];
    $database = ltrim($url['path'], '/');
}

And my default database connection set as:

'default' => 'pgsql'

Then in my connections array:

'pgsql' => [
    'driver' => 'pgsql',
    'url' => $url,
    'host' => $host,
    'database' => $database,
    'username' => $username,
    'password' => $password,
    'charset' => 'utf8',
    'prefix' => '',
    'prefix_indexes' => true,
    'schema' => 'public',
    'sslmode' => 'prefer',
    'port' => env('DB_PORT', '5432'),
],

I have tried googling for a solution but no luck. What do i need to do to fix this please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire