File tree Expand file tree Collapse file tree 1 file changed +40
-5
lines changed Expand file tree Collapse file tree 1 file changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,53 @@ Install dependencies
1010composer 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
2661Example Controller
2762-------
You can’t perform that action at this time.
0 commit comments