saulob
saulob

Reputation: 645

Does Laravel close automatically the DB connections?

I'm working with Laravel and Databases (DB) using Eloquent and MySQL.

I already found the code to close the DB connection, but I was searching on the Documentation if Laravel close all the connections automatically after any use of it.

Before using Laravel, every time I used a MySQL command I opened the database connection on the page header and closed it on the page footer.

But, what about using Laravel/Eloquent? Does it close? Or do I need to close manually all the connections after using it?

Like, basic example using Laravel/Eloquent:

$user = new User;
$user->name = 'John';
$user->save();

I know that on the beginning Laravel opens a connection to the Database/User table. But after saving, does it close it?

Upvotes: 11

Views: 19697

Answers (1)

lud
lud

Reputation: 2001

Yes.

With PHP and with Laravel connections are automatically closed at the end of the script.

Upvotes: 15

Related Questions