Skip to content

TimmyGuy/php-8-routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-8-routing

Static routing class using PHP 8 components

Special thanks to SteamPixel

This routing system is based on SteamPixels routing system

Features

Router

  • Register new routes
  • Run router

Extension

  • Attribute to put above function and classes
  • Demo application class for custom MVC routing

Register a new route

The register accepts 3 paramers.

Name Optional Type
$path No String
$function No Callable OR Array(class, function)
$method Yes String OR Array ('POST', 'GET')

Register it manually

Router::register('/',
function () {
    echo "Hello World"; // Echo's "Hello World" on your screen
}, 
'POST'); 

Or using the attribute, which you can later find with the PHP ReflectionAPI

class MyClass {
    #[Route('/')]
    function MyFunction() {
        echo "Hello World";
    }
}

View the MVC Demo for full demo, or look into the MVC Application class to see how the attributes are read.

About

Static routing class using PHP 8 components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages