PHP code example of phpdot / routing-rt

1. Go to this page and download the library: Download phpdot/routing-rt 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/ */

    

phpdot / routing-rt example snippets


use PHPdot\Routing\RouterRT\Router\RouterRT;

$app = new RouterRT($container, $responseFactory);

// HTTP — exactly the phpdot/routing API
$app->get('/chat/{room}', [ChatPageController::class, 'show']);

// WebSocket
$app->ws('/chat/{room}', [ChatController::class, 'index']);

// SSE
$app->sse('/dashboard/{id:int}', [DashboardController::class, 'stream']);

$app->ws('/chat/{room}', [ChatController::class, 'index'])
    ->name('ws.chat')
    ->middleware(AuthMiddleware::class);