PDO Exception:SQLSTATE[HY000] [2006] MySQL server has gone away with xampp

I'm trying to connect to the database and fetching some records but I'm getting error: Error i'm getting

I'm using Slim PHP framework and slim-twig to render views so my code for the connection file is:

<?php

use Payment\App;
use Illuminate\Database\Capsule\Manager as Capsule;

session_start();

require __DIR__ . '/../vendor/autoload.php';

$app = new App;

$capsule = new Capsule;

$capsule->addConnection([
  'driver' => 'mysql',
  'host' => 'localhost:8080',
  'database' => 'payment',
  'username' => 'root',
  'password' => '',
  'charset' => 'utf8',
  'collation' => 'utf8_unicode_ci',
  'prefix' => ''
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();
require __DIR__ . '/../app/routes.php';

?>

I had also configured my php.ini file properties like max_execution_time & max_allowed_packets but it didn't work and i had also checked that no loop is causing this problem because it takes approx 3 min to show me this error,in this 3 min the it loads.so please anyone can tell me where i'm doing in my code?

Upvotes: 1

Views: 1364

Answers (1)

Ctc
Ctc

Reputation: 801

Probably caused by your packets. The following settings should help: Run this in your MySQL terminal.

 set global max_allowed_packet=104857600

Upvotes: 1

Related Questions