本文整理汇总了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');