1. Go to this page and download the library: Download liuchang103/hyperf-store library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
liuchang103 / hyperf-store example snippets
namespace App\Repository;
use App\Model\Admin;
use App\Server\Message;
class AdminRepository extends \HyperfStore\Repository
{
public $message;
// 注入消息依赖
public function __construct(Message $message)
{
$this->message = $message;
}
// 放入模型
public function build()
{
return new Admin;
}
// 禁止登陆
public function close()
{
$this->model->close = false;
$this->model->save();
// 发送消息
$this->message->send('close');
}
}