PHP Basic and Static Router
Requires PHP 7.4 or newer.
Here's a basic usage example:
Set Your Website Url Via "Config/site.php"
Navigate to "config/routes.php" to start defining your routes
Create Router Instance In "public/index.php" directory:
<?php
declare(strict_types=1);
ERROR_REPORTING(E_ALL);
use FosterRouter\Router\Router;
require_once realpath("../vendor/autoload.php");
$route = new Router();
require $route->routepath("routes");
├── config # Configuration files (routes.php, site.php)
├── public # Web server files (index.php)
├── src # PHP source code (The App namespace)
│ ├── Helper # Helper files
│ ├── Router # Router classes
├── views # Static view files
│ ├── index.php # Index Page
│ ├── 404.php # 404 Page
$route->get('/', 'index');
Static Pages Can Be Created Via The "views" directory.
index
will be automatically converted to "views/index.php"
$route->get('/callback', function(){
echo "Callback Test";
});
$route->post('/demo', function(){
echo "POST Request Test";
});
$route->put('/demo', function(){
echo "PUT Request Test";
});
$route->delete('/demo', function(){
echo "DELETE Request Test";
});
$route->any("/404", "404");