PHP code example of leafs / router

1. Go to this page and download the library: Download leafs/router library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leafs / router example snippets



ET example
app()->get("/", function () {
  response()->json([
    "message" => "Welcome!"
  ]);
});

// MATCH example
app()->match("GET", "/test", function () {
  response()->json([
    "message" => "Test!"
  ]);
});

app()->run();



use Leaf\Router;

get("/", function () {
  echo json_encode([
    "message" => "Welcome!"
  ]);
});

// MATCH example
Router::match("GET", "/test", function () {
  echo json_encode([
    "message" => "Test!"
  ]);
});

Router::run();
bash
php -S localhost:8000