'default', 'dict' => 'small']); Finalseg::init(); echo "[info]", date('H:i:s'), " loaded jieba dictionary!\n"; self::$init = true; } /** * @param string $string * @param string|null $tag */ protected function log($string, $tag = "info") { echo "[{$tag}]", date('H:i:s'), " {$string} \n"; } protected function success($data) { return $this->json(['code' => 0, 'data' => $data]); } /** * @param string $message * @param int $code * @return Response */ protected function error($message = '', $code = -1) { return $this->json(['code' => $code, 'message' => $message]); } public function json($data) { return new Response(200, ['Content-Type' => 'application/json', 'Access-Control-Allow-Origin' => '*', 'Access-Control-Allow-Credentials' => 'true', ], is_string($data) ? $data : json_encode($data, JSON_UNESCAPED_UNICODE)); } /** * @param $string * @return Response */ public function response($string) { return new Response(200, [], $string); } }