vendredi 21 août 2015

Laravel 5 Create Database Connection with User Input

I'm creating a CMS for a small project and need the user to be able to connect to a database during the initial setup.

I'm using a middleware to check whether the database connection is correct (and the tables exist) and if so to run the application. If not, to run the setup.

public function handle($request, Closure $next) {
    if(DB::connection()) {
        return $next($request);
    } else {
        return redirect('/setup');
    }       
}

Essentially, the user will create a database themselves, then supply the database name, username and password during setup which will create a .env file with these details.

However, the application keeps failing with this error:

SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)

Is there a way to make this work? Or is there a better way to go about this?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1U3tiXN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire