kavalanche/router

There is no license information available for the latest version (v1.0.0) of this package.

Router component for web applications

v1.0.0 2024-02-15 21:50 UTC

This package is auto-updated.

Last update: 2024-09-15 23:22:43 UTC


README

Simple routing library for web applications.

Usage

  1. Require kavalanche/router

     composer require kavalanche/router
    
  2. Create Router instance.

     $router = new \Kavalanche\Router\Router();
    
  3. Add your routes.

     $router->get('/', function() {
         echo 'Start';
     });
    
     $router->get('/post(\d+)', function($id) {
         echo 'Post ' . $id;
     });
    
     $router->get('/test/index', [Kavalanche\Router\TestController::class, 'index']);
    
     $controller = new Kavalanche\Router\TestController();
    
     $router->get('/test/post/(\d+)', [$controller, 'post']);
    
  4. Invoke dispatch method.

     $router->dispatch();