ReactPHP for Beginners by Sergey Zhuk

ReactPHP for Beginners by Sergey Zhuk

Author:Sergey Zhuk [Zhuk, Sergey]
Language: eng
Format: epub
Publisher: leanpub.com
Published: 2018-08-04T23:00:00+00:00


Here is the complete version of the handler for the /list route:

// routes.php '/list' => function ( ServerRequestInterface $request, LoopInterface $loop ) { $listFiles = new Process('ls uploads', __DIR__); $listFiles->start($loop); $renderPage = new Process('php pages/list.php', __DIR__); $renderPage->start($loop); $listFiles->stdout->pipe($renderPage->stdin); return new Response( 200, ['Content-Type' => 'text/html'], $renderPage->stdout ); },

Rendering PHP template

Fine. Handler is done and we can continue with a PHP template. Create pages/list.php file with the following contents:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>List of uploads</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.cs\ s"> </head> <body> <div class="container"> <div class="row"> <div class="col-sm-12"> <h1>List of uploads</h1> </div> <ul class="list-group col-sm-6"> <?php foreach($uploads as $upload): ?> <li class="list-group-item"> <?php echo $upload ?> </li> <?php endforeach; ?> </ul> </div> </div> </body> </html>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.