├── .gitignore ├── App ├── Base │ ├── Model.php │ └── UserCenter │ │ ├── Friend.php │ │ ├── Notification.php │ │ ├── User.php │ │ └── UserChat.php ├── Bll │ ├── IndexController.php │ ├── UserCenter │ │ ├── FriendController.php │ │ ├── NotificationController.php │ │ ├── UserCenterController.php │ │ └── UserChatController.php │ └── WebSocket │ │ ├── Parser.php │ │ └── Register.php ├── Com │ ├── DataBase │ │ └── DataBaseInit.php │ ├── FrameInit │ │ └── AutoLoad.php │ ├── Providers │ │ └── UserCenterProvider.php │ ├── Response │ │ ├── CommonCode.php │ │ ├── FrameWorkCode.php │ │ └── MessageType.php │ └── Traits │ │ ├── AbstractControllerTraits.php │ │ ├── AppendTrait.php │ │ ├── FilterTrait.php │ │ ├── OrderByTrait.php │ │ ├── SearchListTrait.php │ │ └── ValidatorTrait.php ├── Logic │ ├── UserCenter │ │ ├── FriendLogic.php │ │ ├── NotificationLogic.php │ │ ├── UserChatLogic.php │ │ └── UserLogic.php │ └── WebSocket │ │ └── UserChatLogic.php ├── Middleware │ ├── CORSMiddleware.php │ ├── SignValidationMiddleware.php │ ├── TokenValidationMiddleware.php │ └── VerifyCsrfToken.php ├── Repository │ └── UserCenter │ │ ├── Contracts │ │ ├── FriendContract.php │ │ ├── NotificationContract.php │ │ ├── UserChatContract.php │ │ └── UserContract.php │ │ └── Instances │ │ ├── FriendRepository.php │ │ ├── NotificationRepository.php │ │ ├── UserChatRepository.php │ │ └── UserRepository.php ├── Router.php ├── Static │ └── 404.html └── Vendor │ ├── Blade │ └── Blade.php │ ├── Hash │ └── Hash.php │ ├── Invoker │ └── Invoker.php │ ├── Redis │ └── Cache.php │ └── Validators │ └── Validator.php ├── Conf ├── Config.php ├── Event.php ├── Helpers.php └── Servlet.php ├── Core ├── AbstractInterface │ ├── AbstractAsyncTask.php │ ├── AbstractController.php │ ├── AbstractEvent.php │ ├── AbstractREST.php │ ├── AbstractRouter.php │ ├── ErrorHandlerInterface.php │ ├── ExceptionHandlerInterface.php │ ├── HttpExceptionHandlerInterface.php │ └── LoggerWriterInterface.php ├── AutoLoader.php ├── Component │ ├── Barrier.php │ ├── Di.php │ ├── Error │ │ ├── ErrorHandler.php │ │ ├── ExceptionHandler.php │ │ └── Trigger.php │ ├── Hook.php │ ├── IO │ │ ├── FileIO.php │ │ └── Stream.php │ ├── Logger.php │ ├── RPC │ │ ├── AbstractInterface │ │ │ ├── AbstractActionRegister.php │ │ │ └── AbstractPackageParser.php │ │ ├── Client │ │ │ ├── Call.php │ │ │ ├── CallList.php │ │ │ └── Client.php │ │ ├── Common │ │ │ ├── ActionList.php │ │ │ ├── Config.php │ │ │ ├── DefaultPackageParser.php │ │ │ └── Package.php │ │ └── Server │ │ │ ├── Server.php │ │ │ └── Service.php │ ├── ShareMemory.php │ ├── Socket │ │ ├── AbstractInterface │ │ │ ├── AbstractClient.php │ │ │ ├── AbstractCommandParser.php │ │ │ └── AbstractCommandRegister.php │ │ ├── Client │ │ │ ├── TcpClient.php │ │ │ └── UdpClient.php │ │ ├── Common │ │ │ ├── Command.php │ │ │ └── CommandList.php │ │ ├── Dispatcher.php │ │ ├── Response.php │ │ └── Type.php │ ├── Spl │ │ ├── SplArray.php │ │ ├── SplBean.php │ │ ├── SplEnum.php │ │ └── SplString.php │ ├── SuperClosure.php │ ├── SysConst.php │ └── Version │ │ ├── AbstractRegister.php │ │ ├── Controller.php │ │ ├── Version.php │ │ └── VersionList.php ├── Core.php ├── Http │ ├── Dispatcher.php │ ├── Message │ │ ├── Message.php │ │ ├── Request.php │ │ ├── Response.php │ │ ├── ServerRequest.php │ │ ├── Status.php │ │ ├── Stream.php │ │ ├── UploadFile.php │ │ └── Uri.php │ ├── Request.php │ ├── Response.php │ ├── Session │ │ ├── Base.php │ │ ├── Request.php │ │ ├── Response.php │ │ ├── Session.php │ │ └── SessionHandler.php │ └── UrlParser.php ├── Swoole │ ├── AsyncTaskManager.php │ ├── Config.php │ ├── Pipe │ │ ├── AbstractCommandRegister.php │ │ ├── CommandList.php │ │ ├── Dispatcher.php │ │ ├── Message.php │ │ └── Send.php │ ├── Server.php │ └── Timer.php ├── Utility │ ├── Curl │ │ ├── Cookie.php │ │ ├── Multi.php │ │ ├── Request.php │ │ ├── Response.php │ │ └── UAGenerate.php │ ├── File.php │ ├── Judge.php │ ├── Random.php │ ├── Sort.php │ └── Validate │ │ ├── Error.php │ │ ├── Field.php │ │ ├── Func.php │ │ ├── Message.php │ │ ├── Rule.php │ │ └── Validate.php └── Vendor │ ├── FastRoute │ ├── BadRouteException.php │ ├── DataGenerator.php │ ├── DataGenerator │ │ ├── CharCountBased.php │ │ ├── GroupCountBased.php │ │ ├── GroupPosBased.php │ │ ├── MarkBased.php │ │ └── RegexBasedAbstract.php │ ├── Dispatcher.php │ ├── Dispatcher │ │ ├── CharCountBased.php │ │ ├── GroupCountBased.php │ │ ├── GroupPosBased.php │ │ ├── MarkBased.php │ │ └── RegexBasedAbstract.php │ ├── Route.php │ ├── RouteCollector.php │ ├── RouteParser.php │ ├── RouteParser │ │ └── Std.php │ └── functions.php │ ├── PhpParser │ ├── Autoloader.php │ ├── Builder.php │ ├── Builder │ │ ├── Class_.php │ │ ├── Declaration.php │ │ ├── FunctionLike.php │ │ ├── Function_.php │ │ ├── Interface_.php │ │ ├── Method.php │ │ ├── Namespace_.php │ │ ├── Param.php │ │ ├── Property.php │ │ ├── Trait_.php │ │ └── Use_.php │ ├── BuilderAbstract.php │ ├── BuilderFactory.php │ ├── Comment.php │ ├── Comment │ │ └── Doc.php │ ├── Error.php │ ├── ErrorHandler.php │ ├── ErrorHandler │ │ ├── Collecting.php │ │ └── Throwing.php │ ├── Lexer.php │ ├── Lexer │ │ └── Emulative.php │ ├── Node.php │ ├── Node │ │ ├── Arg.php │ │ ├── Const_.php │ │ ├── Expr.php │ │ ├── Expr │ │ │ ├── ArrayDimFetch.php │ │ │ ├── ArrayItem.php │ │ │ ├── Array_.php │ │ │ ├── Assign.php │ │ │ ├── AssignOp.php │ │ │ ├── AssignOp │ │ │ │ ├── BitwiseAnd.php │ │ │ │ ├── BitwiseOr.php │ │ │ │ ├── BitwiseXor.php │ │ │ │ ├── Concat.php │ │ │ │ ├── Div.php │ │ │ │ ├── Minus.php │ │ │ │ ├── Mod.php │ │ │ │ ├── Mul.php │ │ │ │ ├── Plus.php │ │ │ │ ├── Pow.php │ │ │ │ ├── ShiftLeft.php │ │ │ │ └── ShiftRight.php │ │ │ ├── AssignRef.php │ │ │ ├── BinaryOp.php │ │ │ ├── BinaryOp │ │ │ │ ├── BitwiseAnd.php │ │ │ │ ├── BitwiseOr.php │ │ │ │ ├── BitwiseXor.php │ │ │ │ ├── BooleanAnd.php │ │ │ │ ├── BooleanOr.php │ │ │ │ ├── Coalesce.php │ │ │ │ ├── Concat.php │ │ │ │ ├── Div.php │ │ │ │ ├── Equal.php │ │ │ │ ├── Greater.php │ │ │ │ ├── GreaterOrEqual.php │ │ │ │ ├── Identical.php │ │ │ │ ├── LogicalAnd.php │ │ │ │ ├── LogicalOr.php │ │ │ │ ├── LogicalXor.php │ │ │ │ ├── Minus.php │ │ │ │ ├── Mod.php │ │ │ │ ├── Mul.php │ │ │ │ ├── NotEqual.php │ │ │ │ ├── NotIdentical.php │ │ │ │ ├── Plus.php │ │ │ │ ├── Pow.php │ │ │ │ ├── ShiftLeft.php │ │ │ │ ├── ShiftRight.php │ │ │ │ ├── Smaller.php │ │ │ │ ├── SmallerOrEqual.php │ │ │ │ └── Spaceship.php │ │ │ ├── BitwiseNot.php │ │ │ ├── BooleanNot.php │ │ │ ├── Cast.php │ │ │ ├── Cast │ │ │ │ ├── Array_.php │ │ │ │ ├── Bool_.php │ │ │ │ ├── Double.php │ │ │ │ ├── Int_.php │ │ │ │ ├── Object_.php │ │ │ │ ├── String_.php │ │ │ │ └── Unset_.php │ │ │ ├── ClassConstFetch.php │ │ │ ├── Clone_.php │ │ │ ├── Closure.php │ │ │ ├── ClosureUse.php │ │ │ ├── ConstFetch.php │ │ │ ├── Empty_.php │ │ │ ├── Error.php │ │ │ ├── ErrorSuppress.php │ │ │ ├── Eval_.php │ │ │ ├── Exit_.php │ │ │ ├── FuncCall.php │ │ │ ├── Include_.php │ │ │ ├── Instanceof_.php │ │ │ ├── Isset_.php │ │ │ ├── List_.php │ │ │ ├── MethodCall.php │ │ │ ├── New_.php │ │ │ ├── PostDec.php │ │ │ ├── PostInc.php │ │ │ ├── PreDec.php │ │ │ ├── PreInc.php │ │ │ ├── Print_.php │ │ │ ├── PropertyFetch.php │ │ │ ├── ShellExec.php │ │ │ ├── StaticCall.php │ │ │ ├── StaticPropertyFetch.php │ │ │ ├── Ternary.php │ │ │ ├── UnaryMinus.php │ │ │ ├── UnaryPlus.php │ │ │ ├── Variable.php │ │ │ ├── YieldFrom.php │ │ │ └── Yield_.php │ │ ├── FunctionLike.php │ │ ├── Name.php │ │ ├── Name │ │ │ ├── FullyQualified.php │ │ │ └── Relative.php │ │ ├── NullableType.php │ │ ├── Param.php │ │ ├── Scalar.php │ │ ├── Scalar │ │ │ ├── DNumber.php │ │ │ ├── Encapsed.php │ │ │ ├── EncapsedStringPart.php │ │ │ ├── LNumber.php │ │ │ ├── MagicConst.php │ │ │ ├── MagicConst │ │ │ │ ├── Class_.php │ │ │ │ ├── Dir.php │ │ │ │ ├── File.php │ │ │ │ ├── Function_.php │ │ │ │ ├── Line.php │ │ │ │ ├── Method.php │ │ │ │ ├── Namespace_.php │ │ │ │ └── Trait_.php │ │ │ └── String_.php │ │ ├── Stmt.php │ │ └── Stmt │ │ │ ├── Break_.php │ │ │ ├── Case_.php │ │ │ ├── Catch_.php │ │ │ ├── ClassConst.php │ │ │ ├── ClassLike.php │ │ │ ├── ClassMethod.php │ │ │ ├── Class_.php │ │ │ ├── Const_.php │ │ │ ├── Continue_.php │ │ │ ├── DeclareDeclare.php │ │ │ ├── Declare_.php │ │ │ ├── Do_.php │ │ │ ├── Echo_.php │ │ │ ├── ElseIf_.php │ │ │ ├── Else_.php │ │ │ ├── Finally_.php │ │ │ ├── For_.php │ │ │ ├── Foreach_.php │ │ │ ├── Function_.php │ │ │ ├── Global_.php │ │ │ ├── Goto_.php │ │ │ ├── GroupUse.php │ │ │ ├── HaltCompiler.php │ │ │ ├── If_.php │ │ │ ├── InlineHTML.php │ │ │ ├── Interface_.php │ │ │ ├── Label.php │ │ │ ├── Namespace_.php │ │ │ ├── Nop.php │ │ │ ├── Property.php │ │ │ ├── PropertyProperty.php │ │ │ ├── Return_.php │ │ │ ├── StaticVar.php │ │ │ ├── Static_.php │ │ │ ├── Switch_.php │ │ │ ├── Throw_.php │ │ │ ├── TraitUse.php │ │ │ ├── TraitUseAdaptation.php │ │ │ ├── TraitUseAdaptation │ │ │ ├── Alias.php │ │ │ └── Precedence.php │ │ │ ├── Trait_.php │ │ │ ├── TryCatch.php │ │ │ ├── Unset_.php │ │ │ ├── UseUse.php │ │ │ ├── Use_.php │ │ │ └── While_.php │ ├── NodeAbstract.php │ ├── NodeDumper.php │ ├── NodeTraverser.php │ ├── NodeTraverserInterface.php │ ├── NodeVisitor.php │ ├── NodeVisitor │ │ └── NameResolver.php │ ├── NodeVisitorAbstract.php │ ├── Parser.php │ ├── Parser │ │ ├── Multiple.php │ │ ├── Php5.php │ │ ├── Php7.php │ │ └── Tokens.php │ ├── ParserAbstract.php │ ├── ParserFactory.php │ ├── PrettyPrinter │ │ └── Standard.php │ ├── PrettyPrinterAbstract.php │ ├── Serializer.php │ ├── Serializer │ │ └── XML.php │ ├── Unserializer.php │ └── Unserializer │ │ └── XML.php │ └── SuperClosure │ ├── Analyzer │ ├── AstAnalyzer.php │ ├── ClosureAnalyzer.php │ ├── Token.php │ ├── TokenAnalyzer.php │ └── Visitor │ │ ├── ClosureLocatorVisitor.php │ │ ├── MagicConstantVisitor.php │ │ └── ThisDetectorVisitor.php │ ├── Exception │ ├── ClosureAnalysisException.php │ ├── ClosureSerializationException.php │ ├── ClosureUnserializationException.php │ └── SuperClosureException.php │ ├── SerializableClosure.php │ ├── Serializer.php │ └── SerializerInterface.php ├── Log ├── default_1801.log ├── default_1802.log ├── default_1804.log ├── error_1801.log ├── error_1802.log ├── error_1804.log └── swoole.log ├── README.md ├── Resource ├── css │ └── style.css ├── images │ ├── a.png │ ├── avatar.jpeg │ └── swoole.png └── screen │ ├── image1.gif │ ├── image1.png │ ├── image2.gif │ ├── image3.gif │ └── image4.gif ├── composer.json ├── composer.lock ├── npm-debug.log ├── server └── unitTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | .env 3 | /.idea/ 4 | /_ide_helper.php 5 | -------------------------------------------------------------------------------- /App/Base/UserCenter/Friend.php: -------------------------------------------------------------------------------- 1 | hasOne(User::class, 'id', 'user_id'); 19 | } 20 | 21 | public function getAvatarAttribute() 22 | { 23 | return Arr::get($this->user, 'avatar', ''); 24 | } 25 | 26 | public function getNameAttribute() 27 | { 28 | return Arr::get($this->user, 'name', ''); 29 | } 30 | 31 | public function getActionNameAttribute() 32 | { 33 | if ($this->attributes['action'] == 'RECEIVE') { 34 | return '已接受'; 35 | } 36 | if ($this->attributes['action'] == 'REFUSE') { 37 | return '已拒绝'; 38 | } 39 | return 'DEFAULT'; 40 | } 41 | } -------------------------------------------------------------------------------- /App/Base/UserCenter/User.php: -------------------------------------------------------------------------------- 1 | hasMany(UserChat::class, 'user_id', 'id'); 21 | } 22 | 23 | /* 24 | * 接收方的聊天记录 25 | */ 26 | public function toUserChats() 27 | { 28 | return $this->hasMany(UserChat::class, 'to_user_id', 'id'); 29 | } 30 | 31 | public function setPasswordAttribute($password) 32 | { 33 | $this->attributes['password'] = password_hash($password, PASSWORD_BCRYPT); 34 | } 35 | } -------------------------------------------------------------------------------- /App/Base/UserCenter/UserChat.php: -------------------------------------------------------------------------------- 1 | hasOne(User::class, 'id', 'user_id'); 19 | } 20 | 21 | 22 | public function fromUser() 23 | { 24 | return $this->hasOne(User::class, 'id', 'to_user_id'); 25 | } 26 | 27 | public function getNameAttribute() 28 | { 29 | return Arr::get($this->user, 'name', ''); 30 | } 31 | 32 | public function getEmailAttribute() 33 | { 34 | return Arr::get($this->user, 'email', ''); 35 | } 36 | 37 | public function getAvatarAttribute() 38 | { 39 | return Arr::get($this->user, 'avatar', ''); 40 | } 41 | 42 | public function filterUserId($q, $user_id) 43 | { 44 | return $q->whereIn('user_id', $user_id); 45 | } 46 | 47 | public function filterToUserId($q, $user_id) 48 | { 49 | return $q->whereIn('to_user_id', $user_id); 50 | } 51 | } -------------------------------------------------------------------------------- /App/Bll/IndexController.php: -------------------------------------------------------------------------------- 1 | render($tplName, $tplData); 17 | $this->response()->write($viewTemplate); 18 | } 19 | } -------------------------------------------------------------------------------- /App/Bll/WebSocket/Parser.php: -------------------------------------------------------------------------------- 1 | setCommand($data['action']); 19 | } 20 | if (isset($data['content'])) { 21 | $result->setMessage($data); 22 | } 23 | } 24 | } 25 | 26 | 27 | } -------------------------------------------------------------------------------- /App/Com/DataBase/DataBaseInit.php: -------------------------------------------------------------------------------- 1 | getConf('DATABASE'); 16 | $capsule = new Capsule; 17 | //连接数据库 18 | $capsule->addConnection($dbConf); 19 | //设置全局静态可访问 20 | $capsule->setAsGlobal(); 21 | // 启动Eloquent 22 | $capsule->bootEloquent(); 23 | } 24 | 25 | static function getInstance() 26 | { 27 | if ( !isset(self::$instance)) { 28 | self::$instance = new static(); 29 | } 30 | return self::$instance; 31 | } 32 | } -------------------------------------------------------------------------------- /App/Com/FrameInit/AutoLoad.php: -------------------------------------------------------------------------------- 1 | requireFile('vendor/autoload.php'); 15 | $loader->requireFile('Conf/Helpers.php'); 16 | date_default_timezone_set('Asia/Shanghai'); 17 | } 18 | 19 | static function getInstance() 20 | { 21 | if ( !isset(self::$instance)) { 22 | self::$instance = new static(); 23 | } 24 | return self::$instance; 25 | } 26 | } -------------------------------------------------------------------------------- /App/Com/Providers/UserCenterProvider.php: -------------------------------------------------------------------------------- 1 | di = Di::getInstance(); 23 | $this->conf(); 24 | } 25 | 26 | static function getInstance() 27 | { 28 | if ( !isset(self::$instance)) { 29 | self::$instance = new static(); 30 | } 31 | return self::$instance; 32 | } 33 | 34 | public function conf() 35 | { 36 | $this->di->set(UserContract::class, UserRepository::class); 37 | $this->di->set(UserChatContract::class, UserChatRepository::class); 38 | $this->di->set(NotificationContract::class, NotificationRepository::class); 39 | $this->di->set(FriendContract::class, FriendRepository::class); 40 | } 41 | } -------------------------------------------------------------------------------- /App/Com/Response/CommonCode.php: -------------------------------------------------------------------------------- 1 | View('errors.404'); 20 | // TODO: Implement actionNotFound() method. 21 | } 22 | 23 | function afterAction() 24 | { 25 | // TODO: Implement afterAction() method. 26 | } 27 | } -------------------------------------------------------------------------------- /App/Com/Traits/OrderByTrait.php: -------------------------------------------------------------------------------- 1 | orderByRaw($order_by); 24 | else { 25 | foreach ($order_by as $order) { 26 | list($field, $dir) = $order_by; 27 | 28 | $query->orderBy($field, $dir); 29 | } 30 | return $query; 31 | } 32 | 33 | } 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /App/Com/Traits/ValidatorTrait.php: -------------------------------------------------------------------------------- 1 | make($data, $rules, $messages); 14 | 15 | if ($validator->fails()) { 16 | 17 | return [ 18 | 'is_valid' => false, 19 | 'errors' => $validator->errors(), 20 | ]; 21 | } 22 | 23 | return [ 24 | 'is_valid' => true, 25 | 'errors' => [] 26 | ]; 27 | } 28 | } -------------------------------------------------------------------------------- /App/Logic/UserCenter/FriendLogic.php: -------------------------------------------------------------------------------- 1 | pluck('to_user_id'); 19 | $userList = User::whereIn('id', $userIds)->get(); 20 | return $userList; 21 | } 22 | 23 | /** 24 | * 获取好友信息 25 | * @param $params 26 | * @return mixed 27 | */ 28 | public function getFriendInfo($params) 29 | { 30 | $userInfo = User::where('id', $params['user_id'])->first(); 31 | return $userInfo; 32 | } 33 | 34 | /** 35 | * 插入数据 36 | * @param $params 37 | * @return mixed 38 | */ 39 | public function insert($params) 40 | { 41 | $userInfo = Friend::create($params); 42 | return $userInfo; 43 | } 44 | } -------------------------------------------------------------------------------- /App/Logic/UserCenter/UserChatLogic.php: -------------------------------------------------------------------------------- 1 | beginTransaction(); 20 | $result = UserChat::create($params); 21 | if ( !$result) { 22 | Manager::connection()->rollBack(); 23 | return response()->exception(FrameWorkCode::ADD_ERROR); 24 | } 25 | Manager::connection()->commit(); 26 | return true; 27 | } catch (\Exception $e) { 28 | Manager::connection()->rollBack(); 29 | Logger::getInstance()->log($e); 30 | return response()->exception(FrameWorkCode::ADD_ERROR); 31 | } catch (\Throwable $e) { 32 | Manager::connection()->rollBack(); 33 | Logger::getInstance()->log($e); 34 | return response()->exception(FrameWorkCode::STATUS_EXCEPTION); 35 | }; 36 | } 37 | } -------------------------------------------------------------------------------- /App/Logic/WebSocket/UserChatLogic.php: -------------------------------------------------------------------------------- 1 | getConf("PUBLIC_USER_LIST"); 18 | cache()->hdel('userlist', $params['fd']); 19 | $content = array_unique(cache()->hvals('userlist')); 20 | $user_list = []; 21 | foreach ($content as $data) { 22 | array_push($user_list, json_decode($data, true)); 23 | } 24 | $user_last['action'] = $title; 25 | $user_last['content'] = $user_list; 26 | $user_list = json_encode($user_last); 27 | foreach (cache()->hkeys('userlist') as $fd) { 28 | $work = $server->connection_info($fd); 29 | if ($work['websocket_status']) { 30 | $server->push($fd, $user_list); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /App/Middleware/CORSMiddleware.php: -------------------------------------------------------------------------------- 1 | withHeader("Cache-Control", "no-cache"); 23 | $response->withHeader('Access-Control-Allow-Origin', Config::getInstance()->getConf("ORIGIN")); 24 | $response->withHeader('Access-Control-Allow-Methods', 'GET,POST,OPTIONS'); 25 | $response->withHeader('Access-Control-Allow-Headers', 'Content-Type,x-requested-with'); 26 | $response->withHeader('Access-Control-Allow-Credentials', 'true'); 27 | } 28 | } -------------------------------------------------------------------------------- /App/Middleware/SignValidationMiddleware.php: -------------------------------------------------------------------------------- 1 | getServerParams(); 24 | if ($server['request_method'] !== "OPTIONS") { 25 | $sign = $request->getRequestParam("sign"); 26 | $encrypt = $request->getUri()->getPath() . Config::getInstance()->getConf('VERSION') . Config::getInstance()->getConf('SALT'); 27 | $encrypt = md5($encrypt); 28 | if ($sign != $encrypt) { 29 | if (Config::getInstance()->getConf('ENV') == 'dev') { 30 | $response->writeJson(500, ['message' => '签名不匹配!', 'sign' => $encrypt], FrameWorkCode::FLAG_NOTICE); 31 | } else { 32 | $response->exception(FrameWorkCode::ERROR_SIGN); 33 | } 34 | return $response->end(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /App/Middleware/TokenValidationMiddleware.php: -------------------------------------------------------------------------------- 1 | getServerParams(); 27 | if ($server['request_method'] !== "OPTIONS") { 28 | $not_login = Servlet::getInstance()->getConf("NOT_LOGIN"); 29 | $path = $request->getUri()->getPath(); 30 | if ( !in_array($path, $not_login)) { 31 | $token = $request->getRequestParam("token"); 32 | if ( !$token) { 33 | $response->exception(FrameWorkCode::ERROR_TOKEN); 34 | return $response->end(); 35 | } 36 | $token = (new Parser())->parse($token); 37 | $data = new ValidationData(); 38 | if ( !$token->validate($data)) { 39 | $response->exception(FrameWorkCode::ERROR_TOKEN); 40 | return $response->end(); 41 | } 42 | } 43 | } 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /App/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | getMethod(); 10 | if ( !in_array($method, ['HEAD', 'GET', 'OPTIONS'])) { 11 | $token = $request->getRequestParam('_token'); 12 | if ( !$token) { 13 | $response->writeJson(500, 'The token is miss!', 'fail'); 14 | $response->end(); 15 | } 16 | if ( !hash_equals($token, $request->session()->get('_token'))) { 17 | $response->writeJson(500, 'The token is verified fail!', 'fail'); 18 | $response->end(); 19 | } 20 | } else { 21 | $session_token = $request->session()->get('_token'); 22 | if ( !$session_token) { 23 | $response->session()->set('_token', Str::random(40)); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /App/Repository/UserCenter/Contracts/FriendContract.php: -------------------------------------------------------------------------------- 1 | newInstanceArgs(); 14 | $method = $reflection->getMethod($method); 15 | return $method->invokeArgs($instance, [$params]); 16 | } 17 | } -------------------------------------------------------------------------------- /App/Vendor/Redis/Cache.php: -------------------------------------------------------------------------------- 1 | getConf('REDIS'); 35 | $connection = !is_null($connection) ? $connection : 'default'; 36 | $driver = !is_null($driver) ? $driver : 'predis'; 37 | $prefix = !is_null($prefix) ? $prefix : 'es'; 38 | $redis = new \Illuminate\Redis\RedisManager($driver, $config); 39 | $cache = new RedisStore($redis, $prefix, $connection); 40 | return $cache; 41 | } 42 | } -------------------------------------------------------------------------------- /App/Vendor/Validators/Validator.php: -------------------------------------------------------------------------------- 1 | conf(); 15 | $this->conf = new SplArray($conf); 16 | } 17 | 18 | static function getInstance() 19 | { 20 | if ( !isset(self::$instance)) { 21 | self::$instance = new static(); 22 | } 23 | return self::$instance; 24 | } 25 | 26 | function getConf($keyPath) 27 | { 28 | return $this->conf->get($keyPath); 29 | } 30 | 31 | /* 32 | * 在server启动以后,无法动态的去添加,修改配置信息(进程数据独立) 33 | */ 34 | function setConf($keyPath, $data) 35 | { 36 | $this->conf->set($keyPath, $data); 37 | } 38 | 39 | function conf() 40 | { 41 | return [ 42 | "NOT_LOGIN" => [ 43 | '/UserCenter/UserCenterController/Login', 44 | '/UserCenter/UserCenterController/Register', 45 | '/UserCenter/UserCenterController/SendCode' 46 | ], 47 | ]; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /Core/AbstractInterface/AbstractREST.php: -------------------------------------------------------------------------------- 1 | actionNotFound(); 28 | } 29 | function __call($actionName, $arguments) 30 | { 31 | /* 32 | * restful中无需预防恶意调用控制器内置方法。 33 | */ 34 | $actionName = $this->request()->getMethod().ucfirst($actionName); 35 | //执行onRequest事件 36 | $this->actionName($actionName); 37 | $this->onRequest($actionName); 38 | //判断是否被拦截 39 | if(!$this->response()->isEndResponse()){ 40 | $realName = $this->actionName(); 41 | if(method_exists($this,$realName)){ 42 | $this->$realName(); 43 | }else{ 44 | $this->actionNotFound($realName, $arguments); 45 | } 46 | } 47 | $this->afterAction(); 48 | } 49 | } -------------------------------------------------------------------------------- /Core/AbstractInterface/AbstractRouter.php: -------------------------------------------------------------------------------- 1 | routeCollector = new RouteCollector(new Std(),new GroupCountBased()); 24 | $this->register($this->routeCollector); 25 | } 26 | 27 | abstract function register(RouteCollector $routeCollector); 28 | function getRouteCollector(){ 29 | return $this->routeCollector; 30 | } 31 | function request(){ 32 | return Request::getInstance(); 33 | } 34 | function response(){ 35 | return Response::getInstance(); 36 | } 37 | } -------------------------------------------------------------------------------- /Core/AbstractInterface/ErrorHandlerInterface.php: -------------------------------------------------------------------------------- 1 | tasks[$taskName] = $callable; 30 | return true; 31 | } 32 | function run($timeout = 0.5){ 33 | $temp = array(); 34 | foreach ($this->tasks as $name => $task){ 35 | $temp[] = $task; 36 | $this->maps[] = $name; 37 | } 38 | if(!empty($temp)){ 39 | $ret = Server::getInstance()->getServer()->taskWaitMulti($temp,$timeout); 40 | if(!empty($ret)){ 41 | //极端情况下 所有任务都超时 42 | foreach ($ret as $index => $result){ 43 | $this->results[$this->maps[$index]] = $result; 44 | } 45 | } 46 | } 47 | return $this->results; 48 | } 49 | function getResults(){ 50 | return $this->results; 51 | } 52 | function getResult($taskName){ 53 | if(isset($this->results[$taskName])){ 54 | return $this->results[$taskName]; 55 | }else{ 56 | return null; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Core/Component/Error/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | write(nl2br($msg) ." in file {$file} line {$line}"); 30 | }else{ 31 | Logger::getInstance('error')->console($msg." in file {$file} line {$line}",false); 32 | } 33 | } 34 | 35 | function log($msg,$file = null,$line = null,$errorCode = null, $trace) 36 | { 37 | // TODO: Implement log() method. 38 | Logger::getInstance('error')->log($msg." in file {$file} line {$line}"); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /Core/Component/Error/ExceptionHandler.php: -------------------------------------------------------------------------------- 1 | write(nl2br($exception->getMessage().$exception->getTraceAsString())); 30 | }else{ 31 | Logger::getInstance('error')->console($exception->getMessage().$exception->getTraceAsString(),false); 32 | } 33 | } 34 | 35 | function log(\Exception $exception) 36 | { 37 | // TODO: Implement log() method. 38 | Logger::getInstance('error')->log($exception->getMessage()." ".$exception->getTraceAsString()); 39 | } 40 | } -------------------------------------------------------------------------------- /Core/Component/Hook.php: -------------------------------------------------------------------------------- 1 | eventList[$event] = $callback; 28 | return $this; 29 | } 30 | 31 | function event($event,...$arg){ 32 | if(isset($this->eventList[$event])){ 33 | $handler = $this->eventList[$event]; 34 | try{ 35 | call_user_func_array($handler,$arg); 36 | }catch (\Exception $exception){ 37 | throw $exception; 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Core/Component/IO/FileIO.php: -------------------------------------------------------------------------------- 1 | getStreamResource(),$mode); 22 | } 23 | 24 | function unlock($mode = LOCK_UN){ 25 | return flock($this->getStreamResource(),$mode); 26 | } 27 | } -------------------------------------------------------------------------------- /Core/Component/RPC/AbstractInterface/AbstractActionRegister.php: -------------------------------------------------------------------------------- 1 | package = $package; 22 | $this->successCall = $success; 23 | $this->failCall = $fail; 24 | } 25 | 26 | /** 27 | * @return Package 28 | */ 29 | public function getPackage() 30 | { 31 | return $this->package; 32 | } 33 | 34 | /** 35 | * @return callable 36 | */ 37 | public function getSuccessCall() 38 | { 39 | return $this->successCall; 40 | } 41 | 42 | /** 43 | * @return callable 44 | */ 45 | public function getFailCall() 46 | { 47 | return $this->failCall; 48 | } 49 | } -------------------------------------------------------------------------------- /Core/Component/RPC/Client/CallList.php: -------------------------------------------------------------------------------- 1 | setServerName($serverName); 20 | $package->setAction($action); 21 | $package->setArgs($args); 22 | $this->taskList[] = new Call($package,$successCall,$failCall); 23 | return $this; 24 | } 25 | 26 | function getTaskList(){ 27 | return $this->taskList; 28 | } 29 | } -------------------------------------------------------------------------------- /Core/Component/RPC/Common/ActionList.php: -------------------------------------------------------------------------------- 1 | list[$name] = $call; 18 | } 19 | 20 | function setDefaultAction(callable $call){ 21 | $this->list['__DEFAULT__'] = $call; 22 | } 23 | 24 | function getHandler($name){ 25 | if(isset($this->list[$name])){ 26 | return $this->list[$name]; 27 | }else{ 28 | return isset($this->list['__DEFAULT__']) ? $this->list['__DEFAULT__'] : null; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Core/Component/RPC/Common/DefaultPackageParser.php: -------------------------------------------------------------------------------- 1 | arrayToBean($js); 24 | } 25 | 26 | function encode(Package $res) 27 | { 28 | // TODO: Implement encode() method. 29 | $data = $res->__toString(); 30 | $value = unpack('H*', $data); 31 | return base_convert($value[1], 16, 2); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Core/Component/RPC/Server/Service.php: -------------------------------------------------------------------------------- 1 | actionRegisterClass; 17 | } 18 | 19 | public function setActionRegisterClass($actionRegisterClass) 20 | { 21 | $this->actionRegisterClass = $actionRegisterClass; 22 | } 23 | } -------------------------------------------------------------------------------- /Core/Component/Socket/AbstractInterface/AbstractClient.php: -------------------------------------------------------------------------------- 1 | clientType; 24 | } 25 | 26 | /** 27 | * @param mixed $clientType 28 | */ 29 | public function setClientType($clientType) 30 | { 31 | $this->clientType = $clientType; 32 | } 33 | } -------------------------------------------------------------------------------- /Core/Component/Socket/AbstractInterface/AbstractCommandParser.php: -------------------------------------------------------------------------------- 1 | command; 25 | } 26 | 27 | /** 28 | * @param mixed $command 29 | */ 30 | public function setCommand($command) 31 | { 32 | $this->command = $command; 33 | } 34 | 35 | /** 36 | * @return mixed 37 | */ 38 | public function getMessage() 39 | { 40 | return $this->message; 41 | } 42 | 43 | /** 44 | * @param mixed $message 45 | */ 46 | public function setMessage($message) 47 | { 48 | $this->message = $message; 49 | } 50 | 51 | /** 52 | * @return mixed 53 | */ 54 | public function getClient() 55 | { 56 | return $this->client; 57 | } 58 | 59 | function setClient($client){ 60 | $this->client = $client; 61 | } 62 | 63 | /** 64 | * @return mixed 65 | */ 66 | public function getRawData() 67 | { 68 | return $this->rawData; 69 | } 70 | 71 | /** 72 | * @param mixed $rawData 73 | */ 74 | public function setRawData($rawData) 75 | { 76 | $this->rawData = $rawData; 77 | } 78 | } -------------------------------------------------------------------------------- /Core/Component/Socket/Common/CommandList.php: -------------------------------------------------------------------------------- 1 | list[$commandStr] = $callback; 17 | } 18 | 19 | function setDefaultHandler(callable $callback){ 20 | $this->list['DEFAULT_HANDLER'] = $callback; 21 | } 22 | 23 | function getHandler(Command $command){ 24 | $name = $command->getCommand(); 25 | if(isset($this->list[$name])){ 26 | return $this->list[$name]; 27 | }else if(isset($this->list['DEFAULT_HANDLER'])){ 28 | return $this->list['DEFAULT_HANDLER']; 29 | }else{ 30 | return null; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Core/Component/Socket/Response.php: -------------------------------------------------------------------------------- 1 | getClientType() == Type::WEB_SOCKET){ 22 | return Server::getInstance()->getServer()->push($client->getFd(),$data); 23 | }else{ 24 | return Server::getInstance()->getServer()->send($client->getFd(),$data.$eof,$client->getReactorId()); 25 | } 26 | }else if($client instanceof UdpClient){ 27 | return Server::getInstance()->getServer()->sendto($client->getAddress(),$client->getPort(),$data.$eof); 28 | }else{ 29 | trigger_error( "client is not validate"); 30 | return false; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Core/Component/Socket/Type.php: -------------------------------------------------------------------------------- 1 | selfEnum = $key ? $key : '__default'; 21 | } 22 | 23 | final function equals($val){ 24 | $list = static::enumList(); 25 | return $list[$this->selfEnum] === $val ? true : false; 26 | } 27 | 28 | static function inEnum($enumVal){ 29 | $list = static::enumList(); 30 | $key = array_search($enumVal,$list,true); 31 | return $key ? $key : false; 32 | } 33 | 34 | final static function enumList(){ 35 | $ref = new \ReflectionClass(static::class); 36 | return $ref->getConstants(); 37 | } 38 | 39 | final function __toString() 40 | { 41 | // TODO: Implement __toString() method. 42 | $list = static::enumList(); 43 | $data = $list[$this->selfEnum]; 44 | if(is_string($data)){ 45 | return $data; 46 | }else{ 47 | return json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); 48 | } 49 | } 50 | 51 | final static function __callStatic($name, $arguments) 52 | { 53 | // TODO: Implement __callStatic() method. 54 | $list = static::enumList(); 55 | $val = isset($list[$name]) ? $list[$name] : null; 56 | return new static($val); 57 | } 58 | } -------------------------------------------------------------------------------- /Core/Component/SuperClosure.php: -------------------------------------------------------------------------------- 1 | func = $func; 21 | $this->serializer = new Serializer(); 22 | } 23 | function __sleep() 24 | { 25 | // TODO: Implement __sleep() method. 26 | $this->serializedJson = $this->serializer->serialize($this->func); 27 | $this->isSerialized = 1; 28 | return array("serializedJson",'isSerialized'); 29 | } 30 | function __wakeup() 31 | { 32 | // TODO: Implement __wakeup() method. 33 | $this->serializer = new Serializer(); 34 | $this->func = $this->serializer->unserialize($this->serializedJson); 35 | } 36 | function __invoke() 37 | { 38 | // TODO: Implement __invoke() method. 39 | /* 40 | * prevent call before serialized 41 | */ 42 | $args = func_get_args(); 43 | if($this->isSerialized){ 44 | $func = $this->serializer->unserialize($this->serializedJson); 45 | }else{ 46 | $func = $this->func; 47 | } 48 | return call_user_func_array($func,$args); 49 | } 50 | } -------------------------------------------------------------------------------- /Core/Component/SysConst.php: -------------------------------------------------------------------------------- 1 | versionName = $versionName; 26 | $this->judge = $judge; 27 | $this->routeCollector = new RouteCollector(new Std(),new GroupCountBased()); 28 | } 29 | 30 | function register(){ 31 | return $this->routeCollector; 32 | } 33 | 34 | 35 | function dispatch($urlPath,$requestMethod){ 36 | if($this->dispatcher == null){ 37 | $this->dispatcher = new Dispatcher($this->routeCollector->getData()); 38 | } 39 | return $this->dispatcher->dispatch($requestMethod,$urlPath); 40 | } 41 | 42 | /** 43 | * @return mixed 44 | */ 45 | public function getVersionName() 46 | { 47 | return $this->versionName; 48 | } 49 | 50 | /** 51 | * @return callable 52 | */ 53 | public function getJudge() 54 | { 55 | return $this->judge; 56 | } 57 | 58 | /** 59 | * @return null 60 | */ 61 | public function getDefaultHandler() 62 | { 63 | return $this->defaultHandler; 64 | } 65 | 66 | 67 | 68 | 69 | } -------------------------------------------------------------------------------- /Core/Component/Version/VersionList.php: -------------------------------------------------------------------------------- 1 | list[$name] = $version; 18 | return $version; 19 | } 20 | 21 | function get($name){ 22 | if(isset($this->list[$name])){ 23 | return $this->list[$name]; 24 | } 25 | return null; 26 | } 27 | 28 | function all(){ 29 | return $this->list; 30 | } 31 | } -------------------------------------------------------------------------------- /Core/Http/Message/Response.php: -------------------------------------------------------------------------------- 1 | statusCode; 23 | } 24 | 25 | public function withStatus($code, $reasonPhrase = '') 26 | { 27 | // TODO: Implement withStatus() method. 28 | if($code === $this->statusCode){ 29 | return $this; 30 | }else{ 31 | $this->statusCode = $code; 32 | if(empty($reasonPhrase)){ 33 | $this->reasonPhrase = Status::getReasonPhrase($this->statusCode); 34 | }else{ 35 | $this->reasonPhrase = $reasonPhrase; 36 | } 37 | return $this; 38 | } 39 | } 40 | 41 | public function getReasonPhrase() 42 | { 43 | // TODO: Implement getReasonPhrase() method. 44 | return $this->reasonPhrase; 45 | } 46 | 47 | function withAddedCookie(Cookie $cookie){ 48 | $this->cookies[$cookie->getName()] = $cookie; 49 | return $this; 50 | } 51 | 52 | function getCookies(){ 53 | return $this->cookies; 54 | } 55 | } -------------------------------------------------------------------------------- /Core/Http/Message/Stream.php: -------------------------------------------------------------------------------- 1 | session = Session::getInstance(); 18 | } 19 | 20 | function sessionName($name = null){ 21 | return $this->session->sessionName($name); 22 | } 23 | 24 | function savePath($path = null){ 25 | return $this->session->savePath($path); 26 | } 27 | 28 | function sessionId($sid = null){ 29 | return $this->session->sessionId($sid); 30 | } 31 | 32 | function destroy(){ 33 | return $this->session->destroy(); 34 | } 35 | 36 | function close(){ 37 | return $this->session->close(); 38 | } 39 | 40 | function start(){ 41 | if(!$this->session->isStart()){ 42 | return $this->session->start(); 43 | }else{ 44 | trigger_error("session has start"); 45 | return false; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Core/Http/Session/Request.php: -------------------------------------------------------------------------------- 1 | session->isStart()){ 16 | $this->session->start(); 17 | } 18 | $data = $this->session->read(); 19 | $data = unserialize($data); 20 | if(is_array($data)){ 21 | if(isset($data[$key])){ 22 | return $data[$key]; 23 | }else{ 24 | return $default; 25 | } 26 | }else{ 27 | return $default; 28 | } 29 | } 30 | 31 | function toArray(){ 32 | if(!$this->session->isStart()){ 33 | $this->session->start(); 34 | } 35 | $data = $this->session->read(); 36 | $data = unserialize($data); 37 | if(is_array($data)){ 38 | return $data; 39 | }else{ 40 | return array(); 41 | } 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /Core/Http/Session/Response.php: -------------------------------------------------------------------------------- 1 | session->isStart()){ 16 | $this->session->start(); 17 | } 18 | $data = $this->session->read(); 19 | $data = unserialize($data); 20 | if(!is_array($data)){ 21 | $data = []; 22 | } 23 | $data[$key] = $default; 24 | return $this->session->write(serialize($data)); 25 | } 26 | } -------------------------------------------------------------------------------- /Core/Http/UrlParser.php: -------------------------------------------------------------------------------- 1 | getUri()->getPath(); 17 | } 18 | $basePath = dirname($path); 19 | $info = pathInfo($path); 20 | if($info['filename'] != 'index'){ 21 | if($basePath == '/'){ 22 | $basePath = $basePath.$info['filename']; 23 | }else{ 24 | $basePath = $basePath.'/'.$info['filename']; 25 | } 26 | } 27 | return $basePath; 28 | } 29 | 30 | static public function generateURL($controllerClass,$action = 'index',$query = array()){ 31 | $controllerClass = substr($controllerClass,14); 32 | $controllerClass = explode('\\',$controllerClass); 33 | $path = implode("/",$controllerClass); 34 | if($action == 'index'){ 35 | $path = $path."/index.html"; 36 | }else{ 37 | $path = $path."/{$action}/index.html"; 38 | } 39 | if(!empty($query)){ 40 | return $path."?".http_build_cookie($query); 41 | }else{ 42 | return $path; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Core/Swoole/Pipe/AbstractCommandRegister.php: -------------------------------------------------------------------------------- 1 | list[$command] = $handler; 17 | return $this; 18 | } 19 | 20 | function setDefaultHandler(callable $handler){ 21 | $this->list['__DEFAULT__'] = $handler; 22 | return $this; 23 | } 24 | 25 | function getHandler($command){ 26 | if(isset($this->list[$command])){ 27 | return $this->list[$command]; 28 | }else if(isset($this->list['__DEFAULT__'])){ 29 | return $this->list['__DEFAULT__']; 30 | }else{ 31 | return null; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Core/Swoole/Pipe/Dispatcher.php: -------------------------------------------------------------------------------- 1 | commandList = new CommandList(); 29 | $register = Di::getInstance()->get(SysConst::PIPE_COMMAND_REGISTER); 30 | if($register instanceof AbstractCommandRegister){ 31 | $register->register($this->commandList); 32 | } 33 | } 34 | 35 | /* 36 | * $onCommandWorker 当前(目标)收到信息进程 37 | * $fromProcessId 来自哪个进程的id 38 | */ 39 | function dispatch($onCommandWorker, $fromProcessId,$data){ 40 | $arr = json_decode($data,1); 41 | $arr = is_array($arr) ? $arr : []; 42 | $message = new Message($arr); 43 | $handler = $this->commandList->getHandler($message->getCommand()); 44 | if(is_callable($handler)){ 45 | try{ 46 | call_user_func_array($handler,array( 47 | $onCommandWorker,$fromProcessId,$message 48 | )); 49 | }catch (\Exception $exception){ 50 | trigger_error($exception->getTraceAsString()); 51 | } 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /Core/Swoole/Pipe/Message.php: -------------------------------------------------------------------------------- 1 | command; 25 | } 26 | 27 | /** 28 | * @param mixed $command 29 | */ 30 | public function setCommand($command) 31 | { 32 | $this->command = $command; 33 | } 34 | 35 | /** 36 | * @return mixed 37 | */ 38 | public function getMessage() 39 | { 40 | return $this->message; 41 | } 42 | 43 | /** 44 | * @param mixed $message 45 | */ 46 | public function setMessage($message) 47 | { 48 | $this->message = $message; 49 | } 50 | 51 | 52 | 53 | protected function initialize() 54 | { 55 | // TODO: Implement initialize() method. 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /Core/Swoole/Pipe/Send.php: -------------------------------------------------------------------------------- 1 | getServer()->sendMessage($message->__toString(),$workerId); 18 | } 19 | } -------------------------------------------------------------------------------- /Core/Swoole/Timer.php: -------------------------------------------------------------------------------- 1 | task投递到task进程池中执行 18 | * 1.8.0以上可分配给task worker 19 | * $microSeconds 最大不得超过 86400000 毫秒 20 | * @return timerId 21 | 22 | */ 23 | static function loop($microSeconds,\Closure $func,$args = null){ 24 | return Server::getInstance()->getServer()->tick($microSeconds,$func,$args); 25 | } 26 | static function delay($microSeconds,\Closure $func,$args = null){ 27 | Server::getInstance()->getServer()->after($microSeconds,$func,$args); 28 | } 29 | /* 30 | * @param $timerId 31 | */ 32 | static function clear($timerId){ 33 | Server::getInstance()->getServer()->clearTimer($timerId); 34 | } 35 | } -------------------------------------------------------------------------------- /Core/Utility/Validate/Error.php: -------------------------------------------------------------------------------- 1 | error = $error; 18 | } 19 | 20 | function first(){ 21 | return array_shift($this->error); 22 | } 23 | 24 | function all(){ 25 | return $this->error; 26 | } 27 | } -------------------------------------------------------------------------------- /Core/Utility/Validate/Field.php: -------------------------------------------------------------------------------- 1 | null 18 | ); 19 | 20 | function withMsg($msg){ 21 | if(isset($this->currentRule)){ 22 | $this->msg[$this->currentRule] = $msg; 23 | $this->currentRule = null; 24 | }else{ 25 | $this->msg['__default__'] = $msg; 26 | } 27 | return $this; 28 | } 29 | 30 | function withRule($rule,...$arg){ 31 | $this->currentRule = $rule; 32 | $this->rule[$rule] = $arg; 33 | return $this; 34 | } 35 | 36 | function getRule(){ 37 | return $this->rule; 38 | } 39 | 40 | function getMsg(){ 41 | return $this->msg; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /Core/Utility/Validate/Message.php: -------------------------------------------------------------------------------- 1 | error = $error; 18 | } 19 | 20 | function hasError(){ 21 | return !empty($this->error); 22 | } 23 | 24 | function getError($filed){ 25 | if(isset($this->error[$filed])){ 26 | return new Error($this->error[$filed]); 27 | }else{ 28 | /* 29 | * 预防调用错误 30 | */ 31 | return new Error(array()); 32 | } 33 | } 34 | 35 | function all(){ 36 | return $this->error; 37 | } 38 | 39 | function first(){ 40 | if($this->hasError()){ 41 | return new Error(array_shift($this->error)); 42 | }else{ 43 | /* 44 | * 预防调用错误 45 | */ 46 | return new Error(array()); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Core/Utility/Validate/Rule.php: -------------------------------------------------------------------------------- 1 | map[$field])){ 19 | $instance = $this->map[$field]; 20 | }else{ 21 | $instance = new Field(); 22 | $this->map[$field] = $instance; 23 | } 24 | return $instance; 25 | } 26 | 27 | function validate(array $data){ 28 | $error = array(); 29 | $data = new SplArray($data); 30 | foreach ($this->map as $filed => $fieldInstance){ 31 | $rules = $fieldInstance->getRule(); 32 | $msg = $fieldInstance->getMsg(); 33 | if(isset($rules[Rule::OPTIONAL]) && empty($data->get($filed))){ 34 | continue; 35 | }else{ 36 | foreach ($rules as $rule => $args){ 37 | if(!Func::$rule($filed,$data,$args)){ 38 | $error[$filed][$rule] = isset($msg[$rule]) ? $msg[$rule] : $msg['__default__']; 39 | } 40 | } 41 | } 42 | } 43 | return new Message($error); 44 | } 45 | } -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/BadRouteException.php: -------------------------------------------------------------------------------- 1 | $route) { 18 | $suffixLen++; 19 | $suffix .= "\t"; 20 | 21 | $regexes[] = '(?:' . $regex . '/(\t{' . $suffixLen . '})\t{' . ($count - $suffixLen) . '})'; 22 | $routeMap[$suffix] = [$route->handler, $route->variables]; 23 | } 24 | 25 | $regex = '~^(?|' . implode('|', $regexes) . ')$~'; 26 | return ['regex' => $regex, 'suffix' => '/' . $suffix, 'routeMap' => $routeMap]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/DataGenerator/GroupCountBased.php: -------------------------------------------------------------------------------- 1 | $route) { 15 | $numVariables = count($route->variables); 16 | $numGroups = max($numGroups, $numVariables); 17 | 18 | $regexes[] = $regex . str_repeat('()', $numGroups - $numVariables); 19 | $routeMap[$numGroups + 1] = [$route->handler, $route->variables]; 20 | 21 | ++$numGroups; 22 | } 23 | 24 | $regex = '~^(?|' . implode('|', $regexes) . ')$~'; 25 | return ['regex' => $regex, 'routeMap' => $routeMap]; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/DataGenerator/GroupPosBased.php: -------------------------------------------------------------------------------- 1 | $route) { 15 | $regexes[] = $regex; 16 | $routeMap[$offset] = [$route->handler, $route->variables]; 17 | 18 | $offset += count($route->variables); 19 | } 20 | 21 | $regex = '~^(?:' . implode('|', $regexes) . ')$~'; 22 | return ['regex' => $regex, 'routeMap' => $routeMap]; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/DataGenerator/MarkBased.php: -------------------------------------------------------------------------------- 1 | $route) { 15 | $regexes[] = $regex . '(*MARK:' . $markName . ')'; 16 | $routeMap[$markName] = [$route->handler, $route->variables]; 17 | 18 | ++$markName; 19 | } 20 | 21 | $regex = '~^(?|' . implode('|', $regexes) . ')$~'; 22 | return ['regex' => $regex, 'routeMap' => $routeMap]; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Dispatcher.php: -------------------------------------------------------------------------------- 1 | 'value', ...]] 18 | * 19 | * @param string $httpMethod 20 | * @param string $uri 21 | * 22 | * @return array 23 | */ 24 | public function dispatch($httpMethod, $uri); 25 | } 26 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Dispatcher/CharCountBased.php: -------------------------------------------------------------------------------- 1 | staticRouteMap, $this->variableRouteData) = $data; 8 | } 9 | 10 | protected function dispatchVariableRoute($routeData, $uri) { 11 | foreach ($routeData as $data) { 12 | if (!preg_match($data['regex'], $uri . $data['suffix'], $matches)) { 13 | continue; 14 | } 15 | 16 | list($handler, $varNames) = $data['routeMap'][end($matches)]; 17 | 18 | $vars = []; 19 | $i = 0; 20 | foreach ($varNames as $varName) { 21 | $vars[$varName] = $matches[++$i]; 22 | } 23 | return [self::FOUND, $handler, $vars]; 24 | } 25 | 26 | return [self::NOT_FOUND]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Dispatcher/GroupCountBased.php: -------------------------------------------------------------------------------- 1 | staticRouteMap, $this->variableRouteData) = $data; 8 | } 9 | 10 | protected function dispatchVariableRoute($routeData, $uri) { 11 | foreach ($routeData as $data) { 12 | if (!preg_match($data['regex'], $uri, $matches)) { 13 | continue; 14 | } 15 | 16 | list($handler, $varNames) = $data['routeMap'][count($matches)]; 17 | 18 | $vars = []; 19 | $i = 0; 20 | foreach ($varNames as $varName) { 21 | $vars[$varName] = $matches[++$i]; 22 | } 23 | return [self::FOUND, $handler, $vars]; 24 | } 25 | 26 | return [self::NOT_FOUND]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Dispatcher/GroupPosBased.php: -------------------------------------------------------------------------------- 1 | staticRouteMap, $this->variableRouteData) = $data; 8 | } 9 | 10 | protected function dispatchVariableRoute($routeData, $uri) { 11 | foreach ($routeData as $data) { 12 | if (!preg_match($data['regex'], $uri, $matches)) { 13 | continue; 14 | } 15 | 16 | // find first non-empty match 17 | for ($i = 1; '' === $matches[$i]; ++$i); 18 | 19 | list($handler, $varNames) = $data['routeMap'][$i]; 20 | 21 | $vars = []; 22 | foreach ($varNames as $varName) { 23 | $vars[$varName] = $matches[$i++]; 24 | } 25 | return [self::FOUND, $handler, $vars]; 26 | } 27 | 28 | return [self::NOT_FOUND]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Dispatcher/MarkBased.php: -------------------------------------------------------------------------------- 1 | staticRouteMap, $this->variableRouteData) = $data; 8 | } 9 | 10 | protected function dispatchVariableRoute($routeData, $uri) { 11 | foreach ($routeData as $data) { 12 | if (!preg_match($data['regex'], $uri, $matches)) { 13 | continue; 14 | } 15 | 16 | list($handler, $varNames) = $data['routeMap'][$matches['MARK']]; 17 | 18 | $vars = []; 19 | $i = 0; 20 | foreach ($varNames as $varName) { 21 | $vars[$varName] = $matches[++$i]; 22 | } 23 | return [self::FOUND, $handler, $vars]; 24 | } 25 | 26 | return [self::NOT_FOUND]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/Route.php: -------------------------------------------------------------------------------- 1 | httpMethod = $httpMethod; 28 | $this->handler = $handler; 29 | $this->regex = $regex; 30 | $this->variables = $variables; 31 | } 32 | 33 | /** 34 | * Tests whether this route matches the given string. 35 | * 36 | * @param string $str 37 | * 38 | * @return bool 39 | */ 40 | public function matches($str) { 41 | $regex = '~^' . $this->regex . '$~'; 42 | return (bool) preg_match($regex, $str); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Core/Vendor/FastRoute/RouteParser.php: -------------------------------------------------------------------------------- 1 | addStmt($stmt); 23 | } 24 | 25 | return $this; 26 | } 27 | 28 | /** 29 | * Sets doc comment for the declaration. 30 | * 31 | * @param PhpParser\Comment\Doc|string $docComment Doc comment to set 32 | * 33 | * @return $this The builder instance (for fluid interface) 34 | */ 35 | public function setDocComment($docComment) { 36 | $this->attributes['comments'] = array( 37 | $this->normalizeDocComment($docComment) 38 | ); 39 | 40 | return $this; 41 | } 42 | } -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Builder/Function_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | /** 24 | * Adds a statement. 25 | * 26 | * @param Node|PhpParser\Builder $stmt The statement to add 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function addStmt($stmt) { 31 | $this->stmts[] = $this->normalizeNode($stmt); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Returns the built function node. 38 | * 39 | * @return Stmt\Function_ The built function node 40 | */ 41 | public function getNode() { 42 | return new Stmt\Function_($this->name, array( 43 | 'byRef' => $this->returnByRef, 44 | 'params' => $this->params, 45 | 'returnType' => $this->returnType, 46 | 'stmts' => $this->stmts, 47 | ), $this->attributes); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Builder/Namespace_.php: -------------------------------------------------------------------------------- 1 | name = null !== $name ? $this->normalizeName($name) : null; 21 | } 22 | 23 | /** 24 | * Adds a statement. 25 | * 26 | * @param Node|PhpParser\Builder $stmt The statement to add 27 | * 28 | * @return $this The builder instance (for fluid interface) 29 | */ 30 | public function addStmt($stmt) { 31 | $this->stmts[] = $this->normalizeNode($stmt); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Adds multiple statements. 38 | * 39 | * @param array $stmts The statements to add 40 | * 41 | * @return $this The builder instance (for fluid interface) 42 | */ 43 | public function addStmts(array $stmts) { 44 | foreach ($stmts as $stmt) { 45 | $this->addStmt($stmt); 46 | } 47 | 48 | return $this; 49 | } 50 | 51 | /** 52 | * Returns the built node. 53 | * 54 | * @return Node The built node 55 | */ 56 | public function getNode() { 57 | return new Stmt\Namespace_($this->name, $this->stmts); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Comment/Doc.php: -------------------------------------------------------------------------------- 1 | errors[] = $error; 20 | } 21 | 22 | /** 23 | * Get collected errors. 24 | * 25 | * @return Error[] 26 | */ 27 | public function getErrors() { 28 | return $this->errors; 29 | } 30 | 31 | /** 32 | * Check whether there are any errors. 33 | * 34 | * @return bool 35 | */ 36 | public function hasErrors() { 37 | return !empty($this->errors); 38 | } 39 | 40 | /** 41 | * Reset/clear collected errors. 42 | */ 43 | public function clearErrors() { 44 | $this->errors = []; 45 | } 46 | } -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/ErrorHandler/Throwing.php: -------------------------------------------------------------------------------- 1 | value = $value; 27 | $this->byRef = $byRef; 28 | $this->unpack = $unpack; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('value', 'byRef', 'unpack'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Const_.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->dim = $dim; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'dim'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/ArrayItem.php: -------------------------------------------------------------------------------- 1 | key = $key; 27 | $this->value = $value; 28 | $this->byRef = $byRef; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('key', 'value', 'byRef'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Array_.php: -------------------------------------------------------------------------------- 1 | items = $items; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('items'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Assign.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->expr = $expr; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'expr'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/AssignOp.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->expr = $expr; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'expr'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->expr = $expr; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'expr'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/BinaryOp.php: -------------------------------------------------------------------------------- 1 | left = $left; 24 | $this->right = $right; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('left', 'right'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/BooleanNot.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Cast.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Cast/Array_.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->name = $name; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'name'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Clone_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/ClosureUse.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->byRef = $byRef; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'byRef'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/ConstFetch.php: -------------------------------------------------------------------------------- 1 | name = $name; 22 | } 23 | 24 | public function getSubNodeNames() { 25 | return array('name'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Empty_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Error.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Eval_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Exit_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('expr'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/FuncCall.php: -------------------------------------------------------------------------------- 1 | name = $name; 25 | $this->args = $args; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('name', 'args'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Include_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 29 | $this->type = $type; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('expr', 'type'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Instanceof_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 25 | $this->class = $class; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('expr', 'class'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Isset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/List_.php: -------------------------------------------------------------------------------- 1 | items = $items; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('items'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/MethodCall.php: -------------------------------------------------------------------------------- 1 | var = $var; 28 | $this->name = $name; 29 | $this->args = $args; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('var', 'name', 'args'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/New_.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->args = $args; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'args'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/PostDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/PostInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/PreDec.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/PreInc.php: -------------------------------------------------------------------------------- 1 | var = $var; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('var'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Print_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/PropertyFetch.php: -------------------------------------------------------------------------------- 1 | var = $var; 24 | $this->name = $name; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('var', 'name'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/ShellExec.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('parts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/StaticCall.php: -------------------------------------------------------------------------------- 1 | class = $class; 28 | $this->name = $name; 29 | $this->args = $args; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('class', 'name', 'args'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/StaticPropertyFetch.php: -------------------------------------------------------------------------------- 1 | class = $class; 25 | $this->name = $name; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('class', 'name'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Ternary.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 27 | $this->if = $if; 28 | $this->else = $else; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('cond', 'if', 'else'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/UnaryMinus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/UnaryPlus.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Variable.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/YieldFrom.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Expr/Yield_.php: -------------------------------------------------------------------------------- 1 | key = $key; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('key', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/FunctionLike.php: -------------------------------------------------------------------------------- 1 | type = $type; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('type'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Param.php: -------------------------------------------------------------------------------- 1 | type = $type; 33 | $this->byRef = $byRef; 34 | $this->variadic = $variadic; 35 | $this->name = $name; 36 | $this->default = $default; 37 | } 38 | 39 | public function getSubNodeNames() { 40 | return array('type', 'byRef', 'variadic', 'name', 'default'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Scalar.php: -------------------------------------------------------------------------------- 1 | parts = $parts; 22 | } 23 | 24 | public function getSubNodeNames() { 25 | return array('parts'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Scalar/EncapsedStringPart.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Scalar/MagicConst.php: -------------------------------------------------------------------------------- 1 | num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Case_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Catch_.php: -------------------------------------------------------------------------------- 1 | types = $types; 27 | $this->var = $var; 28 | $this->stmts = $stmts; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('types', 'var', 'stmts'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/ClassConst.php: -------------------------------------------------------------------------------- 1 | flags = $flags; 24 | $this->consts = $consts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('flags', 'consts'); 29 | } 30 | 31 | public function isPublic() { 32 | return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 33 | || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; 34 | } 35 | 36 | public function isProtected() { 37 | return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); 38 | } 39 | 40 | public function isPrivate() { 41 | return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); 42 | } 43 | 44 | public function isStatic() { 45 | return (bool) ($this->flags & Class_::MODIFIER_STATIC); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/ClassLike.php: -------------------------------------------------------------------------------- 1 | stmts as $stmt) { 21 | if ($stmt instanceof ClassMethod) { 22 | $methods[] = $stmt; 23 | } 24 | } 25 | return $methods; 26 | } 27 | 28 | /** 29 | * Gets method with the given name defined directly in this class/interface/trait. 30 | * 31 | * @param string $name Name of the method (compared case-insensitively) 32 | * 33 | * @return ClassMethod|null Method node or null if the method does not exist 34 | */ 35 | public function getMethod($name) { 36 | $lowerName = strtolower($name); 37 | foreach ($this->stmts as $stmt) { 38 | if ($stmt instanceof ClassMethod && $lowerName === strtolower($stmt->name)) { 39 | return $stmt; 40 | } 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Const_.php: -------------------------------------------------------------------------------- 1 | consts = $consts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('consts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Continue_.php: -------------------------------------------------------------------------------- 1 | num = $num; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('num'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/DeclareDeclare.php: -------------------------------------------------------------------------------- 1 | value pair node. 16 | * 17 | * @param string $key Key 18 | * @param Node\Expr $value Value 19 | * @param array $attributes Additional attributes 20 | */ 21 | public function __construct($key, Node\Expr $value, array $attributes = array()) { 22 | parent::__construct($attributes); 23 | $this->key = $key; 24 | $this->value = $value; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('key', 'value'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Declare_.php: -------------------------------------------------------------------------------- 1 | declares = $declares; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('declares', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Do_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Echo_.php: -------------------------------------------------------------------------------- 1 | exprs = $exprs; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('exprs'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/ElseIf_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Else_.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('stmts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Finally_.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('stmts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/For_.php: -------------------------------------------------------------------------------- 1 | array(): Init expressions 23 | * 'cond' => array(): Loop conditions 24 | * 'loop' => array(): Loop expressions 25 | * 'stmts' => array(): Statements 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct(array $subNodes = array(), array $attributes = array()) { 29 | parent::__construct($attributes); 30 | $this->init = isset($subNodes['init']) ? $subNodes['init'] : array(); 31 | $this->cond = isset($subNodes['cond']) ? $subNodes['cond'] : array(); 32 | $this->loop = isset($subNodes['loop']) ? $subNodes['loop'] : array(); 33 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('init', 'cond', 'loop', 'stmts'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Global_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Goto_.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/GroupUse.php: -------------------------------------------------------------------------------- 1 | type = $type; 28 | $this->prefix = $prefix; 29 | $this->uses = $uses; 30 | } 31 | 32 | public function getSubNodeNames() { 33 | return array('type', 'prefix', 'uses'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/HaltCompiler.php: -------------------------------------------------------------------------------- 1 | remaining = $remaining; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('remaining'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/If_.php: -------------------------------------------------------------------------------- 1 | array(): Statements 24 | * 'elseifs' => array(): Elseif clauses 25 | * 'else' => null : Else clause 26 | * @param array $attributes Additional attributes 27 | */ 28 | public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array()) { 29 | parent::__construct($attributes); 30 | $this->cond = $cond; 31 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 32 | $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array(); 33 | $this->else = isset($subNodes['else']) ? $subNodes['else'] : null; 34 | } 35 | 36 | public function getSubNodeNames() { 37 | return array('cond', 'stmts', 'elseifs', 'else'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/InlineHTML.php: -------------------------------------------------------------------------------- 1 | value = $value; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('value'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Interface_.php: -------------------------------------------------------------------------------- 1 | array(): Name of extended interfaces 18 | * 'stmts' => array(): Statements 19 | * @param array $attributes Additional attributes 20 | */ 21 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 22 | parent::__construct($attributes); 23 | $this->name = $name; 24 | $this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array(); 25 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('name', 'extends', 'stmts'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Label.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Namespace_.php: -------------------------------------------------------------------------------- 1 | name = $name; 28 | $this->stmts = $stmts; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('name', 'stmts'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Nop.php: -------------------------------------------------------------------------------- 1 | flags = $flags; 27 | $this->type = $flags; 28 | $this->props = $props; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('flags', 'props'); 33 | } 34 | 35 | public function isPublic() { 36 | return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 37 | || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; 38 | } 39 | 40 | public function isProtected() { 41 | return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); 42 | } 43 | 44 | public function isPrivate() { 45 | return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); 46 | } 47 | 48 | public function isStatic() { 49 | return (bool) ($this->flags & Class_::MODIFIER_STATIC); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/PropertyProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->default = $default; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'default'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Return_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/StaticVar.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | $this->default = $default; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('name', 'default'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Static_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Switch_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->cases = $cases; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'cases'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Throw_.php: -------------------------------------------------------------------------------- 1 | expr = $expr; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('expr'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/TraitUse.php: -------------------------------------------------------------------------------- 1 | traits = $traits; 25 | $this->adaptations = $adaptations; 26 | } 27 | 28 | public function getSubNodeNames() { 29 | return array('traits', 'adaptations'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/TraitUseAdaptation.php: -------------------------------------------------------------------------------- 1 | trait = $trait; 26 | $this->method = $method; 27 | $this->newModifier = $newModifier; 28 | $this->newName = $newName; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('trait', 'method', 'newModifier', 'newName'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php: -------------------------------------------------------------------------------- 1 | trait = $trait; 23 | $this->method = $method; 24 | $this->insteadof = $insteadof; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('trait', 'method', 'insteadof'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Trait_.php: -------------------------------------------------------------------------------- 1 | array(): Statements 15 | * @param array $attributes Additional attributes 16 | */ 17 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { 18 | parent::__construct($attributes); 19 | $this->name = $name; 20 | $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array(); 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('name', 'stmts'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/TryCatch.php: -------------------------------------------------------------------------------- 1 | stmts = $stmts; 27 | $this->catches = $catches; 28 | $this->finally = $finally; 29 | } 30 | 31 | public function getSubNodeNames() { 32 | return array('stmts', 'catches', 'finally'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Unset_.php: -------------------------------------------------------------------------------- 1 | vars = $vars; 21 | } 22 | 23 | public function getSubNodeNames() { 24 | return array('vars'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/UseUse.php: -------------------------------------------------------------------------------- 1 | getLast(); 27 | } 28 | 29 | parent::__construct($attributes); 30 | $this->type = $type; 31 | $this->name = $name; 32 | $this->alias = $alias; 33 | } 34 | 35 | public function getSubNodeNames() { 36 | return array('type', 'name', 'alias'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/Use_.php: -------------------------------------------------------------------------------- 1 | type = $type; 37 | $this->uses = $uses; 38 | } 39 | 40 | public function getSubNodeNames() { 41 | return array('type', 'uses'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/Node/Stmt/While_.php: -------------------------------------------------------------------------------- 1 | cond = $cond; 24 | $this->stmts = $stmts; 25 | } 26 | 27 | public function getSubNodeNames() { 28 | return array('cond', 'stmts'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Vendor/PhpParser/NodeTraverserInterface.php: -------------------------------------------------------------------------------- 1 | name === 'this') { 23 | $this->detected = true; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Vendor/SuperClosure/Exception/ClosureAnalysisException.php: -------------------------------------------------------------------------------- 1 | 本项目采用swoole作为首选,采用easySwoole作为首选框架,它是一款基于Swoole Server 开发的常驻内存型的分布式PHP框架,专为API而生,摆脱传统PHP运行模式在进程唤起和文件加载上带来的性能损失。 3 | EasySwoole 高度封装了 Swoole Server 而依旧维持 Swoole Server 原有特性,支持同时混合监听HTTP、自定义TCP、UDP协议,让开发者以最低的学习成本和精力编写出多进程,可异步,高可用的应用服务。 4 | 具体可以看文档https://www.easyswoole.com/Manual/2.x/Cn/_book/ 5 | 6 | ### 1.简介 7 | 本人为了更加便利的开发,自行实现了中间件,封装了请求数据体,利用jwt实现api的token验证,集成了Laravel的ORM, 8 | 再次封装了一套适合api编写流程的数据请求流程,具体可以看App/Base目录下的Model类,具体开发步骤详见代码即可。 9 | 10 | ### 2.主要实现 11 | - 登录注册,验证码发送(如果需要测试,可以结合前端react将验证码打印出来即可) 12 | - 公共聊天室(一旦用户登录,用户列表即会增加,该用户可以进行加好友操作) 13 | - 消息推送(可以利用swoole的异步进程实现) 14 | - 私聊室 (加完好友即可进行私聊) 15 | - 其余功能可以添加...... 16 | 17 | ### 3.安装 18 | **这里只是后台逻辑,前端的对应项目请移步到:** https://github.com/LaravelChen/React-Small-Chat 19 | ``` 20 | php server start 21 | ``` 22 | 因为swoole常驻内存,所以一旦修改代码,需要重启。 23 | 24 | 25 | ### 4.项目效果 26 | #### 4.1 畅聊室 27 | ![image](https://github.com/LaravelChen/React-Small-Chat/raw/master/screen/image1.gif) 28 | ![image](https://github.com/LaravelChen/React-Small-Chat/raw/master/screen/image2.gif) 29 | #### 4.2 私聊室 30 | ![image](https://github.com/LaravelChen/React-Small-Chat/raw/master/screen/image3.gif) 31 | ![image](https://github.com/LaravelChen/React-Small-Chat/raw/master/screen/image4.gif) 32 | 33 | **此外,还有其他的加好友,消息推送等效果不演示了,可以自行下载安装使用,效果很好!** -------------------------------------------------------------------------------- /Resource/css/style.css: -------------------------------------------------------------------------------- 1 | .color{ 2 | color: #00d1b2; 3 | } -------------------------------------------------------------------------------- /Resource/images/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/images/a.png -------------------------------------------------------------------------------- /Resource/images/avatar.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/images/avatar.jpeg -------------------------------------------------------------------------------- /Resource/images/swoole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/images/swoole.png -------------------------------------------------------------------------------- /Resource/screen/image1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/screen/image1.gif -------------------------------------------------------------------------------- /Resource/screen/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/screen/image1.png -------------------------------------------------------------------------------- /Resource/screen/image2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/screen/image2.gif -------------------------------------------------------------------------------- /Resource/screen/image3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/screen/image3.gif -------------------------------------------------------------------------------- /Resource/screen/image4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaravelChen/swoole_chat_framework/cff2ae3d970112ab0743500d63c84567f9461ccd/Resource/screen/image4.gif -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravelchen/swoole_framework", 3 | "license": "MIT", 4 | "authors": [ 5 | { 6 | "name": "LaravelChen", 7 | "email": "848407695@qq.com" 8 | } 9 | ], 10 | "require": { 11 | "illuminate/database": "^5.5", 12 | "jenssegers/blade": "^1.1", 13 | "illuminate/pagination": "^5.5", 14 | "illuminate/validation": "^5.5", 15 | "illuminate/cache": "^5.5", 16 | "illuminate/redis": "^5.5", 17 | "predis/predis": "^1.1", 18 | "overtrue/easy-sms": "^1.0", 19 | "lcobucci/jwt": "^3.2", 20 | "illuminate/hashing": "^5.5", 21 | "illuminate/encryption": "^5.5" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "App\\": "App/", 26 | "Conf\\": "Conf/", 27 | "Core\\": "Core/" 28 | } 29 | }, 30 | "require-dev": { 31 | "eaglewu/swoole-ide-helper": "dev-master" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /npm-debug.log: -------------------------------------------------------------------------------- 1 | 0 info it worked if it ends with ok 2 | 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ] 3 | 2 info using npm@3.10.8 4 | 3 info using node@v6.9.1 5 | 4 verbose stack Error: ENOENT: no such file or directory, open '/Users/apple/Code/Swoole_Chat/swoole_chat_framework/package.json' 6 | 4 verbose stack at Error (native) 7 | 5 verbose cwd /Users/apple/Code/Swoole_Chat/swoole_chat_framework 8 | 6 error Darwin 17.4.0 9 | 7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start" 10 | 8 error node v6.9.1 11 | 9 error npm v3.10.8 12 | 10 error path /Users/apple/Code/Swoole_Chat/swoole_chat_framework/package.json 13 | 11 error code ENOENT 14 | 12 error errno -2 15 | 13 error syscall open 16 | 14 error enoent ENOENT: no such file or directory, open '/Users/apple/Code/Swoole_Chat/swoole_chat_framework/package.json' 17 | 15 error enoent ENOENT: no such file or directory, open '/Users/apple/Code/Swoole_Chat/swoole_chat_framework/package.json' 18 | 15 error enoent This is most likely not a problem with npm itself 19 | 15 error enoent and is related to npm not being able to find a file. 20 | 16 verbose exit [ -2, true ] 21 | -------------------------------------------------------------------------------- /unitTest.php: -------------------------------------------------------------------------------- 1 | frameWorkInitialize(); --------------------------------------------------------------------------------