使用workerman/mqtt 做物聯網通訊,需要資料儲存和laravel-admin互通,感覺在laravel下使用workerman不是熟練,所以在workerman裡直接 composer require laravel
下面是測試DB程式,測試透過感覺可以用了!記錄下。
<?php
require __DIR__ . '/vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
$capsule->setAsGlobal();
$users = Capsule::table('test')->get();
print_r($users);
本作品採用《CC 協議》,轉載必須註明作者和本文連結