国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

想問下W大佬,為什么Remove WebServer

marsColin

大佬能說下為什么刪除這個組件呢,另外有沒有什么替代的組件可以使用,低端萌新求解答

2955 3 1
3個回答

xiasha11

降到低版本

  • 暫無評論
walkor 打賞

后面會單獨(dú)出一個增強(qiáng)版的mvc框架。
如果你現(xiàn)在需要可以自己寫個,代碼類似如下:

<?php
use \Workerman\Worker;
use Workerman\Protocols\Http\Request;
use Workerman\Protocols\Http\Response;
use Workerman\Connection\TcpConnection;

require_once __DIR__ . '/vendor/autoload.php';

$web = new Worker("http://0.0.0.0:9988");

// 網(wǎng)站根目錄,假設(shè)在web下
define('WEBROOT', __DIR__ . DIRECTORY_SEPARATOR . 'web');

$web->onMessage = function (TcpConnection $connection, Request $request) {
    $path = $request->path();
    if ($path === '/') {
        $connection->send(exec_php_file(WEBROOT.'/index.html'));
        return;
    }
    $file = realpath(WEBROOT. $path);
    if (false === $file) {
        $connection->send(new Response(404, array(), '<h3>404 Not Found</h3>'));
        return;
    }
    // Security check! Very important!!!
    if (strpos($file, WEBROOT) !== 0) {
        $connection->send(new Response(400));
        return;
    }
    if (\pathinfo($file, PATHINFO_EXTENSION) === 'php') {
        $connection->send(exec_php_file($file));
        return;
    }

    if (!empty($if_modified_since = $request->header('if-modified-since'))) {
        // Check 304.
        $info = \stat($file);
        $modified_time = $info ? \date('D, d M Y H:i:s', $info['mtime']) . ' ' . \date_default_timezone_get() : '';
        if ($modified_time === $if_modified_since) {
            $connection->send(new Response(304));
            return;
        }
    }
    $connection->send((new Response())->withFile($file));
};

function exec_php_file($file) {
    \ob_start();
    // Try to include php file.
    try {
        include $file;
    } catch (\Exception $e) {
        echo $e;
    }
    return \ob_get_clean();
}

// 如果不是在根目錄啟動,則運(yùn)行runAll方法
if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}
  • 暫無評論
marsColin

謝謝大佬的回復(fù),我現(xiàn)在也在之前的webserver的源碼,非常感謝

  • 暫無評論
年代過于久遠(yuǎn),無法發(fā)表回答
??