Skip to content

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

License

Notifications You must be signed in to change notification settings

joypurchase0/php-router

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

## Router

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


**PHP Router**, a simple, powerful, and modern PHP routing class with support for Middlewares and Controllers — now updated for PHP 8.2+ compatibility and actively maintained by [Joy Kalyan](https://joykalyan.guru).

![Tests](https://github.com/joypurchase0/router/actions/workflows/run-tests.yml/badge.svg)

---

### 🔥 Fork Highlights (Joy Kalyan Edition)

- PHP 8.2 deprecation fixes
- Composer package renamed: `joypurchase0/router`
- Drop-in replacement for `izniburak/router` with the same API
- Actively maintained by Joy Kalyan: [joykalyan.guru](https://joykalyan.guru)

---

### ✨ Features
- Supports GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD, AJAX and ANY request methods
- Easy integration with `symfony/http-foundation`
- Controller support (`HomeController@about`)
- Before and After Middlewares
- Static & Dynamic Routes
- Custom route patterns with RegExp
- Namespace & Route Grouping
- Custom 404 & Exception handling
- Debug mode for dev-friendly errors

---

## 🚀 Install

Install it via Composer:

composer require joypurchase0/router


Or manually add it to your `composer.json`:

```json
{
  "require": {
    "joypurchase0/router": "^2.0"
  }
}

Then run:

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;

// Basic GET route
$router->get('/', function(Request $request, Response $response) {
    return $response->setContent('Hello World');
});

// GET with Controller
$router->get('/test', 'TestController@main');

// Auto-discovered controller routes
$router->controller('/users', 'UserController');

$router->run();

📚 Docs

See original documentation on Buki\Router Wiki
Changelog available at: Buki\Router Changelogs


🙌 Credits


🤝 Contributing

  1. Fork this repo ( https://github.com/joypurchase0/router )
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit changes (git commit -am 'Add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request 🚀

📬 Contact

Joy Kalyan
🌐 joykalyan.guru
📧 joypurchase0@gmail.com
🐙 github.com/joypurchase0


📄 License

MIT License

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%