PHPackages                             zaingithub/router - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zaingithub/router

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zaingithub/router
=================

Simple PHP router class.

06PHP

Since Jun 16Pushed 8y agoCompare

[ Source](https://github.com/zaingithub/Router)[ Packagist](https://packagist.org/packages/zaingithub/router)[ RSS](/packages/zaingithub-router/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Macaw
=====

[](#macaw)

Macaw is a simple, open source PHP router. It's super small (~150 LOC), fast, and has some great annotated source code. This class allows you to just throw it into your project and start using it immediately.

### Install

[](#install)

If you have Composer, just include Macaw as a project dependency in your `composer.json`. If you don't just install it by downloading the .ZIP file and extracting it to your project directory.

```
require: {
    "noahbuscher/macaw": "dev-master"
}

```

### Examples

[](#examples)

First, `use` the Macaw namespace:

```
use \NoahBuscher\Macaw\Macaw;
```

Macaw is not an object, so you can just make direct operations to the class. Here's the Hello World:

```
Macaw::get('/', function() {
  echo 'Hello world!';
});

Macaw::dispatch();
```

Macaw also supports lambda URIs, such as:

```
Macaw::get('/(:any)', function($slug) {
  echo 'The slug is: ' . $slug;
});

Macaw::dispatch();
```

You can also make requests for HTTP methods in Macaw, so you could also do:

```
Macaw::get('/', function() {
  echo 'I
