2017 © Pedro Peláez
 

library routify

Simple router based on Express router

image

siro/routify

Simple router based on Express router

  • Wednesday, August 10, 2016
  • by SiroDiaz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Routify

Build Status Scrutinizer Code Quality, (*1)

A simple PHP router inspired in Express framework., (*2)

Routify is a fast and flexible router for PHP 5.4 and higher., (*3)

  • Flexible regular expression routing (inspired by Express)
  • Concrete use. Focused in do well one thing
  • Easy to learn. Simple API that will remember you Express or Slim

Getting started

  1. PHP 5.4.x is required
  2. Install Routify using Composer (recommended) or manually
  3. Setup URL rewriting so that all requests are handled by index.php, for example, using an .htaccess file

Example

require 'vendor/autoload.php';

$router = new Routify\Router();

$middleware1 = function() {
    echo "middleware 1";
};

$middleware2 = function() {
    echo "middleware 2";
};

$router->get('/', function() {
        echo "This is an action";
    },
    ['before' => $middleware1, 'after' => $middleware2]
);

$router->get('/post/:slug/:id', function($slug, $id) {
    echo "You are seeing the post nº $id, with title: $slug";
});

$router->post('/new', function() {
    // something for the POST /new
});

$router->put('/', function() {
    // something for the PUT /
});

$router->delete('/:id', function($id) {
    // something for the DELETE /:id
});

$router->both('/hello/world', function() {
    // something for GET and POST requests
}, ['GET', 'POST']);

$router->any('/bye', function() {
    // something for any request method
}, ['before' => $middleware1, 'after' => $middleware2]);

// regular expression route
$router->get('/(login|logout), function() {
    // response for the login or logout route requested
});

$router->run();

Tests and submit code

New features or modifications must be tested with PHPUnit previously to pull requests of new code., (*4)

The Versions

10/08 2016

dev-master

9999999-dev

Simple router based on Express router

  Sources   Download

MIT

The Development Requires

by Siro Diaz

library http router