Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 667 Bytes

slim.md

File metadata and controls

47 lines (31 loc) · 667 Bytes

Slim with Workerman

Copy your app/index.php to start.php.

Change the code

In start.php

Change:

$app->run();

To:

function run(): string
{
    global $app;
    ob_start();

    $app->run();

    return ob_get_clean();
}

And add global $app; before create the $app variable.

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

global $app; // workerman

AppFactory::setContainer(new \DI\Container());
$app = AppFactory::create();

Run your app

php server.php start

View in your browser

http://localhost:8080