@@ -7,6 +7,7 @@ import LogoImg from '@site/static/img/phpss-banner.svg';
77import GithubImg from '@site/static/img/github.svg' ;
88import CodeBlock from '@theme/CodeBlock' ;
99import Navbar from '@theme/Navbar' ;
10+ import CodeExample from './CodeExample' ;
1011
1112import Icon1 from '@site/static/icons/icon1.svg' ;
1213import Icon2 from '@site/static/icons/icon2.svg' ;
@@ -96,36 +97,7 @@ const Index = () => {
9697 < Link className = { styles . button } to = "/docs/general/" > View Full Documentation</ Link >
9798 </ div >
9899 < div className = "flex-1" >
99- < CodeBlock language = "php" title = "server.php" >
100- { `use Amp\\Http\\Server\\HttpErrorException;
101- use Amp\\Http\\Server\\Request;
102- use Amp\\Http\\Server\\Response;
103- use PHPStreamServer\\Core\\Server;
104- use PHPStreamServer\\Plugin\\HttpServer\\HttpServerPlugin;
105- use PHPStreamServer\\Plugin\\HttpServer\\Worker\\HttpServerProcess;
106-
107- $server = new Server();
108-
109- $server->addPlugin(
110- new HttpServerPlugin(), // Register the HTTP server plugin
111- );
112-
113- $server->addWorker(
114- new HttpServerProcess(
115- listen: '0.0.0.0:8080', // Address to listen on
116- count: 2, // Number of worker processes
117- onRequest: function (Request $request): Response {
118- return match ($request->getUri()->getPath()) {
119- '/' => new Response(body: 'Hello world'),
120- '/ping' => new Response(body: 'pong'),
121- default => throw new HttpErrorException(404),
122- };
123- }
124- ),
125- );
126-
127- exit($server->run());` }
128- </ CodeBlock >
100+ < CodeBlock language = "php" title = "server.php" > { CodeExample . trim ( ) } </ CodeBlock >
129101 </ div >
130102 </ div >
131103 </ div >
0 commit comments