• Stars
    star
    236
  • Rank 169,988 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 8 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP Router, which also has rich features like Middlewares and Controllers is simple, useful and flexible router class for PHP.

Router

  _____  _    _ _____             _____             _            
 |  __ \| |  | |  __ \           |  __ \           | |           
 | |__) | |__| | |__) |  ______  | |__) |___  _   _| |_ ___ _ __
 |  ___/|  __  |  ___/  |______| |  _  // _ \| | | | __/ _ \ '__|
 | |    | |  | | |               | | \ \ (_) | |_| | ||  __/ |   
 |_|    |_|  |_|_|               |_|  \_\___/ \__,_|\__\___|_|   

PHP Router, which also has rich features like Middlewares and Controllers is simple and useful router class for PHP.

Tests Total Downloads Latest Stable Version Latest Unstable Version License

Features

  • Supports GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD, AJAX and ANY request methods
  • Easy access and manage Request and Response via symfony/http-foundation package.
  • Controllers support (Example: HomeController@about)
  • Before and after Route Middlewares support
  • Static Route Patterns
  • Dynamic Route Patterns
  • Easy-to-use patterns
  • Adding a new pattern supports. (with RegExp)
  • Namespaces supports.
  • Group Routing
  • Custom 404 and Exception handling
  • Debug mode (Error message open/close)

Install

To install PHP Router, You can run the following command directly at your project path in your console:

$ composer require izniburak/router

OR you can add following lines into the composer.json file manually:

{
    "require": {
        "izniburak/router": "^2.0"
    }
}

Then, run the following command:

$ composer install

Example Usage

require 'vendor/autoload.php';

use Buki\Router\Router;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

$router = new Router;

// For basic GET URI
$router->get('/', function(Request $request, Response $response) {
    $response->setContent('Hello World');
    return $response;

    # OR
    # return 'Hello World!';
});

// For basic GET URI by using a Controller class.
$router->get('/test', 'TestController@main');

// For auto discovering all methods and URIs
$router->controller('/users', 'UserController');

$router->run();

Docs

Documentation page: Buki\Router Docs

Changelogs: Buki\Router Changelogs

Support

izniburak's homepage

izniburak's twitter

Licence

MIT Licence

Contributing

  1. Fork it ( https://github.com/izniburak/php-router/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • izniburak İzni Burak Demirtaş - creator, maintainer

More Repositories

1

pdox

useful query builder class that works with PHP PDO class for simple access your data.
PHP
298
star
2

laravel-auto-routes

Auto Route Generating (Auto-Discovery) Package for Laravel.
PHP
233
star
3

demet

Simple and useful LAMP & LEMP and more stack environments to use on Docker.
Dockerfile
101
star
4

nur

nur - a simple framework for PHP
PHP
64
star
5

pipeline-go

Pipeline pattern for your jobs, tasks, etc.. (Golang)
Go
52
star
6

query-builder

sql query builder library for crystal-lang
Crystal
48
star
7

react-native-starter

React Native Starter Kit
JavaScript
42
star
8

appstore-notifications-go

App Store Server Notification V2 Package for Golang
Go
32
star
9

denetmen

useful micro check library for Crystal Language.
Crystal
23
star
10

qruby

sql query builder library for Ruby.
Ruby
19
star
11

c-programlama-kod-ornekleri

c programming code examples
C
10
star
12

turkish-number

turn integers into the Turkish words for Crystal Language
Crystal
8
star
13

google-bot-curl

php google bot
PHP
8
star
14

bit-permission

PHP bitwise control to check somethings like Permissions, Roles, etc.
PHP
7
star
15

image-processing

Image Processing example codes and algorithms. (C++ and OpenCV)
C++
6
star
16

nur-core

nur framework core files.
PHP
5
star
17

denetmen.js

simple javascript form validator plugin for jquery
JavaScript
3
star
18

aa-api

Anadolu Agency (Anadolu Ajansı) API Client for PHP
PHP
3
star
19

ruby-draw

Ruby Draw / Fixture script for Fifa & Pes fans.. Happy tournaments!
Ruby
3
star
20

easy-crud

simple crud class for php
PHP
2
star
21

redux.php

simple Redux implementation for PHP (for fun)
PHP
2
star
22

blockchain.rb

a simple introduction to Blockchain algorithm. What is Blockchain? Watch to learn:
Ruby
2
star
23

izniburak

1
star
24

jquery.jtwit.js

jQuery Twitter Plugin
JavaScript
1
star
25

react-starter

react starter project (example)
JavaScript
1
star
26

laravel-jotform

Jotform API for Laravel
PHP
1
star
27

laravel-example

PHP
1
star