adriansoftware.de Docs
|

Quick Start

1
Installation

Create a directory and install it using Composer or from GitHub

composer require adrianschubek/router
2
Server Prerequisites

Rewrite all Requests to your index.php file.
If you are using Apache, place this in your .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
3
Setup Router

Setup router and add routes in your index.php

require __DIR__ . "/vendor/autoload.php";

use adrianschubek\Routing\Route;
use adrianschubek\Routing\Router;

$r = new Router();

$r->get("/", function () {
    echo "Hello!";
});

$r->get("/[name]", function ($name) {
    echo "Hello " . $name;
});

$r->dispatch();