Skip to content

Commit

Permalink
Merge pull request jphp-group#257 from UNF0X/patch-3
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
dim-s authored Apr 25, 2018
2 parents 24fa2ad + 1120ab2 commit 32098f1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions exts/jphp-httpserver-ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,38 @@ Check it, open [http://localhost:8888/client-data](http://localhost:8888/hello-w

---

4. **Start server in background**:
1. **Run server with hello world page**.
```php
use php\http\{HttpServer, HttpServerRequest, HttpServerResponse};

// create server at 8888 port, 127.0.0.1 host.
$server = new HttpServer(8888, '127.0.0.1'); // port & host.

// add route with method + path + handler.
$server->route('GET', '/demo-get', function (HttpServerRequest $req, HttpServerResponse $res) {
$res->contentType('text/html');
$text = $req->attribute('text');
$res->contentType('text/html');
$name=$req->queryParameters()['name']; //get GET parameter "name"
$res->body("You name: $name"); //Show get parameter "name"
});

// run server.
$server->run();
```
Check it, open [http://localhost:8888/hello-world](http://localhost:8888/hello-world) in your browser.

---

5. **Start server in background**:

```php
$server->runInBackground(); // run in background thread.
```

---

5. **Stop server, check is running**.
6. **Stop server, check is running**.
```php
if ($server->isRunning()) {
$server->shutdown();
Expand Down

0 comments on commit 32098f1

Please sign in to comment.