PHP code example of omniphp / framework

1. Go to this page and download the library: Download omniphp/framework library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

omniphp / framework example snippets



// server.php
ation;
use OmniPHP\Http\Kernel;
use OmniPHP\Http\Router;
use OmniPHP\Http\Context;
use OmniPHP\Http\Middlewares\ResponseMiddleware;
use Workerman\Worker;

Application::boot(__DIR__);        // BASE_PATH / CONFIG_PATH / RUNTIME_PATH, .env, timezone, log level, crash handler
Application::workerman('server');  // pid/log/stdout under runtime/, Fiber event loop

Router::group('/api', function () {
    Router::get('/hello/{name}', fn(Context $ctx) => ['hello' => $ctx->param('name')]);
}, [new ResponseMiddleware()]);

$http = new Worker('http://0.0.0.0:8080');
$http->count = 4;
$http->onMessage = [Kernel::class, 'handle']; // dispatch → send → access log

Worker::runAll();
bash
php server.php start      # foreground
php server.php start -d   # daemon
php server.php reload     # re-fork workers after a code change