本文整理匯總了PHP中Http::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::run方法的具體用法?PHP Http::run怎麽用?PHP Http::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Http
的用法示例。
在下文中一共展示了Http::run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fread
$return = fread(self::$fp, 4096);
$response->end($return);
return true;
} else {
$response->end(json_encode(call_user_func_array(array(new Manager(), $rte[1] . "_http"), array("request" => $request))));
return true;
}
}
}
}
return false;
}
public static function run($fd)
{
self::$fp = fopen("php://fd/" . $fd, "a");
swoole_set_process_name(self::$name);
self::http_server();
self::start();
}
}
if (!empty($argv[2])) {
Http::$conf_file = $argv[2];
}
if (!empty($argv[3])) {
Http::$host = $argv[3];
}
if (!empty($argv[4])) {
Http::$port = $argv[4];
}
Http::run($argv[1]);
示例2: doRequest
<?php
/**
* @author jan huang <bboyjanhuang@gmail.com>
* @copyright 2016
*
* @link https://www.github.com/janhuang
* @link http://www.fast-d.cn/
*/
include __DIR__ . '/../vendor/autoload.php';
class Http extends \FastD\Swoole\Server\Http
{
/**
* @param \FastD\Http\SwooleServerRequest $request
* @return \FastD\Http\Response
*/
public function doRequest(\FastD\Http\SwooleServerRequest $request)
{
switch ($request->server->getPathInfo()) {
case '/session/set':
$request->session->set('user', ['name' => 'jan', 'age' => 19]);
return $this->html('ok');
case '/session/get':
return $this->json($request->session->toArray());
default:
return $this->html('hello swoole http server');
}
}
}
Http::run('http://0.0.0.0:9527', SWOOLE_PROCESS, ['debug' => true]);
示例3: doRequest
<?php
include __DIR__ . '/../vendor/autoload.php';
class Http extends \FastD\Swoole\Server\Http
{
/**
* @param \FastD\Http\SwooleServerRequest $request
* @return mixed
*/
public function doRequest(\FastD\Http\SwooleServerRequest $request)
{
$request->cookie->set('name', 'jan');
return new \FastD\Http\JsonResponse(['msg' => 'hello world'], 400, ['NAME' => "Jan"]);
}
}
Http::run('http://0.0.0.0:9527');