PHPackages                             yzmcms/route - 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. yzmcms/route

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

yzmcms/route
============

this is min php route.

v1.1.1(6y ago)1152MITPHPPHP &gt;=5.3.0

Since Jul 3Pushed 6y agoCompare

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

READMEChangelogDependenciesVersions (4)Used By (0)

Route
=====

[](#route)

### Install

[](#install)

If you have Composer, just include route 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: {
    "yzmcms/route": "*"
}

```

### Examples

[](#examples)

First, `use` the route namespace:

```
use yzmcms\route\route;
```

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

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

route::exec();
```

route also supports lambda URIs, such as:

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

route::exec();
```

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

```
route::get('/', function() {
  echo 'I'm a GET request!';
});

route::post('/', function() {
  echo 'I'm a POST request!';
});

route::any('/', function() {
  echo 'I can be both a GET and a POST request!';
});

route::exec();
```

Example passing to a controller instead of a closure
----------------------------------------------------

[](#example-passing-to-a-controller-instead-of-a-closure)

---

It's possible to pass the namespace path to a controller instead of the closure: For this demo lets say I have a folder called controllers with a demo.php

index.php:

```
require('vendor/autoload.php');

use yzmcms\route\route;

route::get('/', 'Controllers\demo@index');
route::get('page', 'Controllers\demo@page');
route::get('view/(:num)', 'Controllers\demo@view');

route::exec();
```

demo.php:

```
