PHP code example of luckystar / php-router

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

    

luckystar / php-router example snippets


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

LuckyStar\PhpRouter\BHRouter::$themeFolder = "src/themes/";

LuckyStar\PhpRouter\BHRouter::get("/", 'index.php');

LuckyStar\PhpRouter\BHRouter::get("/about", 'about-page.php');

 LuckyStar\PhpRouter\BHRouter::post("/", function(){
    echo "test";
});

$pages = ['index','header','footer'];
LuckyStar\PhpRouter\BHRouter::get("/", 'index.php', $pages);

LuckyStar\PhpRouter\BHRouter::get('/bloglar/tes/{name}/{surname}', 'bloglar.php');

LuckyStar\PhpRouter\BHRouter::get('/bloglar/tes/{name}/{surname}', function(){
    echo $_GET['name'];
    echo $_GET['surname'];
});

LuckyStar\PhpRouter\BHRouter::noOne("/404", function(){
    echo "there is no such page";
});
bash
 composer