Laravel - How to add new connection to database.php
<p>I need to use several databases in laravel, and i'm trying to create a form to add a new db connection to connections array in config/database.php.</p>

<p>I don't want to add connections manually, but throught a form.</p>

<pre><code>'connections' =&gt; [

    'sqlite' =&gt; [
        'driver' =&gt; 'sqlite',
        'database' =&gt; env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' =&gt; '',
    ],

    'mysql' =&gt; [
        'driver' =&gt; 'mysql',
        'host' =&gt; env('DB_HOST', 'localhost'),
        'port' =&gt; env('DB_PORT', '3306'),
        'database' =&gt; env('DB_DATABASE', 'forge'),
        'username' =&gt; env('DB_USERNAME', 'forge'),
        'password' =&gt; env('DB_PASSWORD', ''),
        'charset' =&gt; 'utf8',
        'collation' =&gt; 'utf8_unicode_ci',
        'prefix' =&gt; '',
        'strict' =&gt; true,
        'engine' =&gt; null,
    ],

    'pgsql' =&gt; [
        'driver' =&gt; 'pgsql',
        'host' =&gt; env('DB_HOST', 'localhost'),
        'port' =&gt; env('DB_PORT', '5432'),
        'database' =&gt; env('DB_DATABASE', 'forge'),
        'username' =&gt; env('DB_USERNAME', 'forge'),
        'password' =&gt; env('DB_PASSWORD', ''),
        'charset' =&gt; 'utf8',
        'prefix' =&gt; '',
        'schema' =&gt; 'public',
        'sslmode' =&gt; 'prefer',
    ],

],
</code></pre>

<p>Thanks</p>