PHPackages                             memcrab/exceptions - 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. memcrab/exceptions

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

memcrab/exceptions
==================

PHP based Exceptions lib for memCrab Core API

1.1.1(4y ago)150.1k↓36.4%1MITPHPPHP &gt;=7.1

Since Feb 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Memcrab/Exceptions)[ Packagist](https://packagist.org/packages/memcrab/exceptions)[ Docs](http://memcrab.com)[ RSS](/packages/memcrab-exceptions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (1)

PHP Router as Composer Library
==============================

[](#php-router-as-composer-library)

### Status

[](#status)

[![Build Status](https://camo.githubusercontent.com/2ec4b6f9f4419a53f377272bfb5b97731a18c09dbb5556d23d5608b78353a94d/68747470733a2f2f7472617669732d63692e6f72672f6e6f6f6e65686f732f726f757465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/noonehos/router)[![Dependency Status](https://camo.githubusercontent.com/77f479410fa378d99b8280888020f97c3f76b9957861c31046c7fd386d00f348/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3538386639306331373630636536303033613465613637362f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/588f90c1760ce6003a4ea676)[![Total Downloads](https://camo.githubusercontent.com/afccf1a434b954b36d36340285677a5d622afbf9b000296a725588220d3be66f/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f726f757465722f646f776e6c6f616473)](https://packagist.org/packages/memcrab/router)[![Latest Stable Version](https://camo.githubusercontent.com/eda6e1468886357018eeaa3e5b587718f745d8a7198d6a632609c68424d4596e/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f726f757465722f76657273696f6e)](https://packagist.org/packages/memcrab/router)[![Latest Unstable Version](https://camo.githubusercontent.com/8f0a0e761039b6a063d953b9acc5480907e69d6f92a6061c44406315e98871e0/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f726f757465722f762f756e737461626c65)](//packagist.org/packages/memcrab/router)[![License](https://camo.githubusercontent.com/1ee2de89a3d0db419f421aee3a5554bf2881c303868e530a70484248b2bc1b7c/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f726f757465722f6c6963656e7365)](https://packagist.org/packages/memcrab/router)[![composer.lock available](https://camo.githubusercontent.com/6bf2d3c0c9738c711c9e2845c79ee57ed6fba7f1fa0afd95e452b16fdbe58b25/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f726f757465722f636f6d706f7365726c6f636b)](https://packagist.org/packages/memcrab/router)

It's php router based on yaml configuration file and support regular expressions in each route condition. Thats help build more accurate routes with only numbers in part of url or with required part of word etc.

Features
--------

[](#features)

- Support RegExp in any kind of route
- Support multiple routings for single url throw different request methods (POST, GET, PUT, DELETE, ...)
- Support full url or just request uri
- All configurations in simple YAML file
- Each route can return already named params (as many params as you want, or as you have in Regular Expression)
- High performance yaml parse throw using updated pecl yaml-ext 2.0.0 for php 7.0
- Strict standart coding with full Typing of params and returns (by php 7.1)
- PSR-4 autoloading compliant structure
- Unit-Testing with PHPUnit
- Easy to use to any framework

Install
-------

[](#install)

`composer require memcrab/router`

Dependencies
------------

[](#dependencies)

php extension YAML:

- for Ubuntu/Debian

```
- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0

```

- for OS X

```
- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0

```

Usage
-----

[](#usage)

- init Router: `memCrab\Router()`
- load routes: `->loadRoutesFromYaml(string $filePath)`
    - $filePath - Path to yaml files with routes
- run matching: `->matchRoute(string $url, string $method)`
    - $url - URL (`http://example.com/posts`) or just request URI of page (`/post`)
    - $method - http request method
- use your router data with:
    - getService() - return component that we call
    - getAction() - return action that will be run from component
    - getParams() - return route regExp params

Yaml Config Example
-------------------

[](#yaml-config-example)

```
routes:
  /:
    GET: [Index, getMain]
  /post/:
    GET:    [Post, get]
    POST:   [Post, add]
    PATCH:  [Post, save]
    DELETE: [Post, delete]
  /post/publish/:
    POST: [Post, setPublishing]
  /catalog/([a-zA-Z0-9]+)-([a-zA-Z0-9]+)/:
    GET: [Catalog, filter, key1, value1]
```

Run Example
-----------

[](#run-example)

```
require_once __DIR__ . "/../vendor/autoload.php";

use memCrab\Router\Router;
use memCrab\Router\RouterException;

try {
  # Initialize Router
  $Router = new Router();
  $Router->loadRoutesFromYaml("../src/routs.example.yaml");

  # Routing
  $Router->matchRoute("http://example.com/post/", "POST");

  # Run your Controller|Service|Component
  $ServiceName = $Router->getService();
  $Service = new $ServiceName();
  $Action = $Router->getAction();
  $Response = $Service->$Action($Router->getParams());
}
catch(RouterException $error){
  $Response = new \YourResponseClass();
  $Response->setErrorResponse($error);
}

$Response->sendHeaders();
$Response->sendContent();
```

TODOS
-----

[](#todos)

- Add support for suffixes - right part of uri that not involved in routing like .html, .php, last "/", etc
- Add support for prefixes - left part of uri that not involved in routing like lang part (uk/us/fr/ru) or geo part (europe/asia), etc

---

**MIT Licensed**

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~550 days

Total

4

Last Release

1727d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/796d3f8f9559efb1274cdced887fdee9d259b0fdb60cef468bdc6674864d77bf?d=identicon)[Memcrab](/maintainers/Memcrab)

---

Top Contributors

[![oleksandr-diudiun](https://avatars.githubusercontent.com/u/2369309?v=4)](https://github.com/oleksandr-diudiun "oleksandr-diudiun (9 commits)")

---

Tags

phpexceptionslibmemcrab

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/memcrab-exceptions/health.svg)

```
[![Health](https://phpackages.com/badges/memcrab-exceptions/health.svg)](https://phpackages.com/packages/memcrab-exceptions)
```

###  Alternatives

[niiknow/bayes

a machine learning lib

6950.0k](/packages/niiknow-bayes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
