# PRipple **Repository Path**: llmingyue/PRipple ## Basic Information - **Project Name**: PRipple - **Description**: PHP-Stream-Study - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-11-01 - **Last Updated**: 2023-11-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### install ```bash composer require cclilshy/p-ripple ``` ### create main file ```bash vim main.php ``` ```php true]; $tcp = TestTcp::new('tcp_worker_name')->bind('tcp://127.0.0.1:3001', $options); $ws = TestWS::new('ws_worker_name')->bind('tcp://127.0.0.1:3002', $options)->protocol(WebSocket::class); $http = Http::new('http_worker_name')->bind('tcp://127.0.0.1:3008', $options); $http->defineRequestHandler(function (Request $request) use ($tcp, $ws) { if ($request->method === 'GET') { $response = new Response( $statusCode = 200, $headers = ['Content-Type' => 'text/html; charset=utf-8'], $body = file_get_contents(__DIR__ . '/example.html') ); } elseif ($request->upload) { $request->handleUpload(function ($info) use ($tcp, $ws) { foreach ($ws->getClients() as $client) { $client->send('上传成功:' . json_encode($info)); } foreach ($tcp->getClients() as $client) { $client->send('上传成功:' . json_encode($info) . PHP_EOL); } }); $response = new Response( $statusCode = 200, $headers = ['Content-Type' => 'text/html; charset=utf-8'], $body = '请勿关闭页面,上传中...' ); $request->wait(); } else { $response = new Response( $statusCode = 200, $headers = ['Content-Type' => 'text/html; charset=utf-8'], $body = 'You submitted:' . json_encode($request->post) ); } $request->client->send($response); }); $pRipple->push($tcp, $ws, $http)->launch(); ``` ### create template file ```bash vim example.html ``` ```html