PHP code example of johannmalmcom / router

1. Go to this page and download the library: Download johannmalmcom/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/ */

    

johannmalmcom / router example snippets




use Router\Route;

// Ordinary
Route::get("/", function() {
    return "Hello, world";
});

Route::post("/", function() {
    return "Hello, post";
});

Route::put("/", function() {
    return "Hello, put";
});

Route::delete("/", function() {
    return "Hello, delete";
});

// Wildcard
Route::get("/wildcard/:id", function() {
    return "Wildcard";
});

// Secret
Route::get("/secret", function() {
    return "Secret";
}, function() {
    return false;
});