mardi 30 janvier 2018

How create service provider (singleton)?

I have such function which create new connection when I call it:

public function newBaseQueryBuilder()
{
   ...
   $host = config('sphinx.connection.host');
   $port = config('sphinx.connection.port');
   $pdo = new \PDO("mysql:host={$host};port={$port};", '', '');
   $connection = new SphinxConnection($pdo);
   ...
}

Have create service provider which create only one connection?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire