Skip to content

Commit ba3471a

Browse files
authored
Update README.md
1 parent f3058c3 commit ba3471a

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,53 @@ Install dependencies
1010
composer install
1111
```
1212

13-
## Run Your Application With PHP’s Webserver
14-
Environment Variables
13+
## Environment Variables
1514
```bash
1615
composer run env
1716
```
1817

19-
Start the server
2018

19+
## Hello World
20+
File: `public/index.php`
21+
22+
```php
23+
<?php
24+
25+
use App\Application;
26+
use App\Routing\Route;
27+
use App\Http\Response;
28+
use App\Http\Request;
29+
30+
require __DIR__ . '/../vendor/autoload.php';
31+
32+
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/../");
33+
$dotenv->load();
34+
35+
// Instantiate App
36+
$app = new Application();
37+
38+
// Add routes
39+
Route::get('/hello/{name}', function (Request $request) {
40+
$name = $request->params->name;
41+
echo ("Hello, $name");
42+
});
43+
44+
$app->run();
45+
46+
```
47+
48+
## PHP built-in server
49+
Run the following command in terminal to start localhost web server, assuming `./public/` is public-accessible directory with `index.php` file:
50+
51+
```bash
52+
cd public/
53+
php -S localhost:8080
54+
```
55+
Or you may quickly test this using :
2156
```bash
22-
composer run serve
57+
php -S localhost:8000 -t public
2358
```
24-
Voila! Enjoy development.
59+
##### Going to http://localhost:8080/hello/world will now display "Hello, world".
2560

2661
Example Controller
2762
-------

0 commit comments

Comments
 (0)