lundi 24 juillet 2017

Getting properly paths in Laravel

I have custom files in directory custom inside App. One file is called update.php, so path is

App\custom\update.php

In update.php I have

$config = include __DIR__ . '/../../app/config/database.php';

$servername = $config['connections']['mysql']['host'];
$username   = $config['connections']['mysql']['username'];
$password   = $config['connections']['mysql']['password'];
$dbname     = $config['connections']['mysql']['database'];

Which reads database credentials. This works perfectly on Laravel 4.2 but doesn't work in Laravel 5.4

For Laravel 5.4 I've changed the path to

$config = include __DIR__ . '/../../../config/database.php';

But the error shows this ../../../ instead to execute it

include(/var/www/html/site/app/custom/../../../config/database.php): failed to open stream: No such file or directory

How can I proper give the path?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire