require_once env('root_path') . 'vendor/workerman/gatewayclient/Gateway.php';
use app\admin\model\Friend;
use think\Controller;
use GatewayClient\Gateway;
use think\Request;
use app\admin\validate\Index as IndexValidata;
use think\Response;
use think\facade\Session;
class Index extends Controller
{
public function index()
{
$arr = ['id'=>1,'name'=>'老赵','url'=>'images/head/1.jpg'];
Session::set('user',$arr);
$friend = Friend::with(['user'=>function($query){
$query->field('id,username,url,autograph');
}])->where('user_id',1)->field('friend_id')->select();
$friend_array=$friend->toArray();
$record = [];
if(!empty($friend_array)){
$route = '../../../public/static/record/'.$friend_array[0]['friend_id'].'.text';
if(file_exists($route)){
$f= fopen($route,'\n\r');
while (!feof($f))
{
for ($i = 0; $i < 10 && !feof($f); $i++) {
$record[] = fgets($f);
}
}
fclose($f);
}
}
$this->assign('record',$record);
$this->assign('user',$arr);
$this->assign('friend',$friend);
return $this->fetch();
}
我下载好了,没composer install之前,能找到,发不出去消息。install之后,就报找不到class了,哪位大佬帮帮忙呀
把类文件手动require进去
老哥,现在类不报错了,但是发不出去消息,客户端直接发能行,帮忙看看呗,千恩万谢。
<?php
namespace app\admin\controller;
require_once env('root_path') . 'vendor/workerman/gatewayclient/Gateway.php';
use app\admin\model\Friend;
use think\Controller;
use GatewayClient\Gateway;
use think\Request;
use app\admin\validate\Index as IndexValidata;
use think\Response;
use think\facade\Session;
class Index extends Controller
{
public function index()
{
$arr = ['id'=>1,'name'=>'老赵','url'=>'images/head/1.jpg'];
Session::set('user',$arr);
$friend = Friend::with(['user'=>function($query){
$query->field('id,username,url,autograph');
}])->where('user_id',1)->field('friend_id')->select();
$friend_array=$friend->toArray();
$record = [];
if(!empty($friend_array)){
$route = '../../../public/static/record/'.$friend_array[0]['friend_id'].'.text';
if(file_exists($route)){
$f= fopen($route,'\n\r');
while (!feof($f))
{
for ($i = 0; $i < 10 && !feof($f); $i++) {
$record[] = fgets($f);
}
}
fclose($f);
}
}
$this->assign('record',$record);
$this->assign('user',$arr);
$this->assign('friend',$friend);
return $this->fetch();
}