Support the ongoing development of Laravel.io →
Configuration Database Eloquent

Hi,

I'm using Eloquent ORM outside of laravel. Its with SLIM Framework.

I'm trying to control the number of new connections threads being opened for every query i make via Eloquent ORM.

My approach is to make persistent connections with MySql DB using the following config.

    'mysql' => array(
        'read' => [
            'host' => '192.168.1.206',
        ],
        'write' => [
            'host' => '192.168.1.206', 
        ],
        'driver' => 'mysql',
        'database' => 'xxxx',
        'username' => 'xxxxx',
        'password' => 'xxxxxxxxxxxxxxxxxxxx',
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'options' => array(
            PDO::ATTR_PERSISTENT => true,
        ),
    ),

But i'm not sure

  1. how to check this up whether the connections are being closed or not?
  2. how do I specify the ORM to use single connection?
  3. do i have to explicitly tell the ORM to close a connection? if yes, how?
Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.