|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>ReactPHP</title> |
| 7 | + |
| 8 | + <style id="css-config"> |
| 9 | + :root { |
| 10 | + --color-base: #2b3e51; |
| 11 | + --color-highlight: #fc4349; |
| 12 | + } |
| 13 | + </style> |
| 14 | + |
| 15 | + <link href="https://fonts.googleapis.com/css?family=Raleway:300,700|Source+Sans+Pro:400,400i,700,700i|Roboto Mono" rel="stylesheet"> |
| 16 | + <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet"> |
| 17 | + <link href="style.css" rel="stylesheet"> |
| 18 | + |
| 19 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script> |
| 20 | +</head> |
| 21 | + |
| 22 | +<body> |
| 23 | +<div class="hero"> |
| 24 | + <div class="wrapper"> |
| 25 | + <p> |
| 26 | + <svg class="logo" xmlns="http://www.w3.org/2000/svg" width="114.801" height="142" viewBox="0 0 114.801 142"> |
| 27 | + <path class="logo-base" d="M0 142V0h62.8c6.532 0 12.565 1.37 18.1 4.1 5.532 2.734 10.3 6.334 14.3 10.8 4 4.47 7.133 9.535 9.4 15.2 2.266 5.668 3.4 11.37 3.4 17.1 0 9.2-2.3 17.568-6.9 25.1-4.6 7.534-10.834 12.97-18.7 16.3l32.4 53.4h-31l-29-47.6H27.6V142H0zm27.6-71.8h34.6c2.53 0 4.9-.6 7.1-1.8 2.2-1.2 4.1-2.83 5.7-4.9 1.6-2.065 2.865-4.5 3.8-7.3.932-2.8 1.4-5.8 1.4-9 0-3.332-.534-6.4-1.6-9.2-1.07-2.8-2.5-5.23-4.3-7.3-1.8-2.066-3.87-3.666-6.2-4.8-2.335-1.13-4.7-1.7-7.1-1.7H27.6v46z"></path> |
| 28 | + <path class="logo-highlight" d="M93.518 33.603c-1.7-4.36-4.052-8.27-7.052-11.726-3.003-3.454-6.6-6.23-10.79-8.327-4.193-2.095-8.726-3.144-13.596-3.144H11.97v120.65h3.398V13.807H62.08c4.19 0 8.157.935 11.896 2.804 3.74 1.87 6.993 4.333 9.77 7.392 2.776 3.06 4.956 6.57 6.544 10.536 1.585 3.967 2.38 8.1 2.38 12.405 0 4.192-.68 8.27-2.04 12.235-1.36 3.967-3.313 7.506-5.863 10.62-2.55 3.12-5.637 5.638-9.26 7.563-3.628 1.93-7.706 2.89-12.236 2.89H36.45v-3.315l-8.834 5.1 8.834 5.1V83.65h28.86c4.53-.34 8.693-1.556 12.49-3.653 3.795-2.095 7.053-4.814 9.77-8.157 2.72-3.34 4.814-7.164 6.288-11.47 1.47-4.304 2.21-8.778 2.21-13.425 0-4.532-.85-8.98-2.548-13.342z"></path> |
| 29 | + </svg> |
| 30 | + </p> |
| 31 | + |
| 32 | + <h1 class="name"><strong>React</strong>PHP</h1> |
| 33 | + </div> |
| 34 | +</div> |
| 35 | +<div class="hero2"> |
| 36 | + <div class="wrapper"> |
| 37 | + <h2>Event-driven, non-blocking I/O with PHP.</h2> |
| 38 | + |
| 39 | + <p> |
| 40 | + React is a low-level library for event-driven programming in |
| 41 | + <a href="http://php.net">PHP</a>. At its core is an event loop, on |
| 42 | + top of which it provides low-level utilities, such as: Streams |
| 43 | + abstraction, async dns resolver, network client/server, http |
| 44 | + client/server, interaction with processes. Third-party libraries can |
| 45 | + use these components to create async network clients/servers and |
| 46 | + more. |
| 47 | + </p> |
| 48 | + </div> |
| 49 | +</div> |
| 50 | +<div class="hero3"> |
| 51 | + <div class="wrapper wrapper--wider"> |
| 52 | + <h2>Core Components</h2> |
| 53 | + |
| 54 | + <div class="gee-gutter-grid"> |
| 55 | + <div class="gee-gutter-unit-4"> |
| 56 | + <a href="https://github.com/reactphp/event-loop" class="box"> |
| 57 | + <h3>Event Loop</h3> |
| 58 | + |
| 59 | + <p>React's core reactor event-loop.</p> |
| 60 | + </a> |
| 61 | + </div> |
| 62 | + <div class="gee-gutter-unit-4"> |
| 63 | + <a href="https://github.com/reactphp/stream" class="box"> |
| 64 | + <h3>Stream</h3> |
| 65 | + |
| 66 | + <p>Asynchronous OO stream wrapper.</p> |
| 67 | + </a> |
| 68 | + </div> |
| 69 | + <div class="gee-gutter-unit-4"> |
| 70 | + <a href="https://github.com/reactphp/promise" class="box"> |
| 71 | + <h3>Promise</h3> |
| 72 | + |
| 73 | + <p>A lightweight implementation of CommonJS Promises/A for PHP.</p> |
| 74 | + </a> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + |
| 78 | + <h2>Socket Components</h2> |
| 79 | + |
| 80 | + <div class="gee-gutter-grid"> |
| 81 | + <div class="gee-gutter-unit-4"> |
| 82 | + <a href="https://github.com/reactphp/socket" class="box"> |
| 83 | + <h3>Socket</h3> |
| 84 | + |
| 85 | + <p>Asynchronous socket server.</p> |
| 86 | + </a> |
| 87 | + </div> |
| 88 | + <div class="gee-gutter-unit-4"> |
| 89 | + <a href="https://github.com/reactphp/socket-client" class="box"> |
| 90 | + <h3>Socket Client</h3> |
| 91 | + |
| 92 | + <p>Asynchronous socket client.</p> |
| 93 | + </a> |
| 94 | + </div> |
| 95 | + <div class="gee-gutter-unit-4"> |
| 96 | + <a href="https://github.com/reactphp/datagram" class="box"> |
| 97 | + <h3>Datagram</h3> |
| 98 | + |
| 99 | + <p>UDP datagram socket client and server.</p> |
| 100 | + </a> |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + |
| 104 | + <h2>HTTP Components</h2> |
| 105 | + |
| 106 | + <div class="gee-gutter-grid"> |
| 107 | + <div class="gee-gutter-unit-4"> |
| 108 | + <a href="https://github.com/reactphp/http" class="box"> |
| 109 | + <h3>HTTP</h3> |
| 110 | + |
| 111 | + <p>Asynchronous HTTP server.</p> |
| 112 | + </a> |
| 113 | + </div> |
| 114 | + <div class="gee-gutter-unit-4"> |
| 115 | + <a href="https://github.com/reactphp/http-client" class="box"> |
| 116 | + <h3>HTTP Client</h3> |
| 117 | + |
| 118 | + <p>Asynchronous HTTP client.</p> |
| 119 | + </a> |
| 120 | + </div> |
| 121 | + <div class="gee-gutter-unit-4"> |
| 122 | + <a href="https://github.com/reactphp/dns" class="box"> |
| 123 | + <h3>DNS</h3> |
| 124 | + |
| 125 | + <p>Asynchronous DNS resolver.</p> |
| 126 | + </a> |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + </div> |
| 130 | +</div> |
| 131 | +<div class="hero4"> |
| 132 | + <div class="wrapper"> |
| 133 | + <h2>Example</h2> |
| 134 | + |
| 135 | + <p>This simple web server written in React responds with "Hello World" for every request.</p> |
| 136 | + |
| 137 | + <pre class="box"><code class="php">require 'vendor/autoload.php'; |
| 138 | + |
| 139 | +$app = function ($request, $response) { |
| 140 | + $response->writeHead(200, array('Content-Type' => 'text/plain')); |
| 141 | + $response->end("Hello World\n"); |
| 142 | +}; |
| 143 | + |
| 144 | +$loop = React\EventLoop\Factory::create(); |
| 145 | +$socket = new React\Socket\Server($loop); |
| 146 | +$http = new React\Http\Server($socket, $loop); |
| 147 | + |
| 148 | +$http->on('request', $app); |
| 149 | +echo "Server running at http://127.0.0.1:1337\n"; |
| 150 | + |
| 151 | +$socket->listen(1337); |
| 152 | +$loop->run();</code></pre> |
| 153 | + </div> |
| 154 | +</div> |
| 155 | +<footer class="footer"> |
| 156 | + <div class="wrapper"> |
| 157 | + <a href="https://github.com/reactphp"><i class="fa fa-github" aria-hidden="true"></i> GitHub</a> |
| 158 | + <a href="https://twitter.com/reactphp"><i class="fa fa-twitter" aria-hidden="true"></i> Twitter</a> |
| 159 | + <a href="irc://irc.freenode.net/reactphp"><i class="fa fa-bars" aria-hidden="true"></i> IRC</a> |
| 160 | + </div> |
| 161 | +</footer> |
| 162 | + |
| 163 | +<script>hljs.configure({classPrefix: ''});hljs.initHighlightingOnLoad();</script> |
| 164 | + |
| 165 | +<style> |
| 166 | +#color-picker { |
| 167 | + position: fixed; |
| 168 | + bottom: 0; |
| 169 | + left: 50%; |
| 170 | + transform: translateX(-50%); |
| 171 | + padding: 5px; |
| 172 | + background: #fff; |
| 173 | + box-shadow: 0 0 5px rgba(0, 0, 0, .5); |
| 174 | +} |
| 175 | + |
| 176 | +#color-picker fieldset { |
| 177 | + display: inline-block; |
| 178 | + white-space: nowrap; |
| 179 | + border: 0; |
| 180 | + padding: 5px; |
| 181 | +} |
| 182 | +</style> |
| 183 | +<form id="color-picker"> |
| 184 | + <fieldset> |
| 185 | + <label>Base</label> |
| 186 | + <input type="color" value="#2B3E51" id="base"> |
| 187 | + </fieldset> |
| 188 | + |
| 189 | + <fieldset> |
| 190 | + <label>Highlight</label> |
| 191 | + <input type="color" value="#FC4349" id="highlight"> |
| 192 | + </fieldset> |
| 193 | +</form> |
| 194 | + |
| 195 | +<script> |
| 196 | + function parseQueryParams(query){ |
| 197 | + if (query.indexOf('?') === 0) { |
| 198 | + query = query.substr(1); |
| 199 | + } |
| 200 | + if (query.indexOf('#') === 0) { |
| 201 | + query = query.substr(1); |
| 202 | + } |
| 203 | + |
| 204 | + if (!query) { |
| 205 | + return {}; |
| 206 | + } |
| 207 | + |
| 208 | + var pairs = query.split('&'); |
| 209 | + var obj = {}, p; |
| 210 | + |
| 211 | + for (var i = 0, n = pairs.length; i < n; i++) { |
| 212 | + if (!pairs[i]) { |
| 213 | + continue; |
| 214 | + } |
| 215 | + |
| 216 | + p = pairs[i].split('='); |
| 217 | + obj[p[0]] = decodeURIComponent(p[1]); |
| 218 | + } |
| 219 | + |
| 220 | + return obj; |
| 221 | + } |
| 222 | + |
| 223 | + function getColors() { |
| 224 | + var query = parseQueryParams(location.hash); |
| 225 | + |
| 226 | + query.base = query.base || '#2b3e51'; |
| 227 | + query.highlight = query.highlight || '#fc4349'; |
| 228 | + |
| 229 | + return query; |
| 230 | + } |
| 231 | + |
| 232 | + function setColors() { |
| 233 | + var colors = getColors(); |
| 234 | + |
| 235 | + document.getElementById('css-config').innerHTML = ':root { --color-base: ' + colors.base + '; --color-highlight: ' + colors.highlight + '; }'; |
| 236 | + } |
| 237 | + |
| 238 | + function changeColor(type, color) { |
| 239 | + var colors = getColors(); |
| 240 | + |
| 241 | + colors[type] = color; |
| 242 | + location.hash = 'base=' + encodeURIComponent(colors.base) + '&highlight=' + encodeURIComponent(colors.highlight); |
| 243 | + } |
| 244 | + |
| 245 | + var base = document.getElementById('base'); |
| 246 | + var highlight = document.getElementById('highlight'); |
| 247 | + |
| 248 | + var colors = getColors(); |
| 249 | + |
| 250 | + base.setAttribute('value', colors.base); |
| 251 | + base.addEventListener('change', function(e) { |
| 252 | + changeColor('base', e.target.value); |
| 253 | + }, false); |
| 254 | + |
| 255 | + highlight.setAttribute('value', colors.highlight); |
| 256 | + highlight.addEventListener('change', function(e) { |
| 257 | + changeColor('highlight', e.target.value); |
| 258 | + }, false); |
| 259 | + |
| 260 | + setColors(); |
| 261 | + window.onhashchange = setColors; |
| 262 | +</script> |
| 263 | +</body> |
| 264 | +</html> |
0 commit comments