PHPackages                             serabass/yaroute - 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. serabass/yaroute

ActiveLibrary

serabass/yaroute
================

05PHPCI failing

Since May 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Serabass/yaroute)[ Packagist](https://packagist.org/packages/serabass/yaroute)[ RSS](/packages/serabass-yaroute/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/5734118f1e8943639c01baf5b8df74dc73acf5077d1e8726baf1f26e5afb77b0/68747470733a2f2f7472617669732d63692e6f72672f53657261626173732f7961726f7574652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Serabass/yaroute)[![StyleCI](https://camo.githubusercontent.com/69abb8f10b7e4acbb981b1774ffb6428ed8cff483851ffbc5a36bbb28fcfb5bd/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3236333035333036342f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/263053064)

**Yaroute** is a simple route-organizer that uses YAML to register routes in Laravel.

1. [Installation](#installation)
2. [Docs](#docs)
3. [Examples](#examples)
4. [Usage](#usage)
5. [Mixins](#mixins)
6. [Regular Expressions presets](#regular-expressions-presets)
7. [Generating YAML](#generating-yaml)

Installation
============

[](#installation)

`$ composer require serabass/yaroute`

Docs
====

[](#docs)

The format of simple route must look like ` / [as ] [uses ]: `

The format of group must look like:

```
 [uses ]:
   / [as ]:
```

Groups can be nested

Examples
========

[](#examples)

```
GET / as home uses guest: HomeController@index
```

This simple config creates a route with url `/`, named `home`, that uses `guest` middleware and executes `HomeController@index` action

```
/api uses api:
  GET /entity: EntityController@list
```

This simple config creates a group that uses `api` middleware and contains `/entity` route

You can see all examples in [Examples directory](./examples).

Usage
=====

[](#usage)

1. Create your `.yaml` file, e.g. `api.yaml` in any directory (e.g. `routes`)
2. Write just one line in your `routes/web.php` or `routes/api.php` and you can register all routes in your `.yaml`

```
\Serabass\Yaroute\Yaroute::registerFile(__DIR__ . '/api.yaml');
```

Simple group config:

```
/api uses api:
  GET /entity: EntityController@list
  GET /entity/{id ~ \d+}: EntityController@get
  POST /entity/{id ~ \d+}: EntityController@save

  GET /entity/{id}/getComments:
    action: EntityController@getComments

  /admin:
    GET /index: AdminController@index
    GET /entity/{id ~ \d+}: AdminController@entity
    /subroute:
      GET /entity/{id ~ \d+}: AdminController@entity
      GET /data/{alias ~ .+}: AdminController@getData
```

It'll be converted to this:

```
    Route::group(['prefix' => 'api', 'uses' => 'api'], function () {
        Route::get('entity', 'EntityController@list');
        Route::get('entity/{id}', 'EntityController@get')->where('id', '\d+');
        Route::post('entity/{id}', 'EntityController@save')->where('id', '\d+');
        Route::get('entity/{id}/getComments', 'EntityController@getComments')->where('id', '\d+');
        Route::group('admin', function () {
            Route::get('index', 'AdminController@index');
            Route::get('entity/{id}', 'AdminController@entity')->where('id', '\d+');
            Route::group('subroute', function () {
                Route::get('entity/{id}', 'AdminController@entity')->where('id', '\d+');
                Route::get('data/{alias}', 'AdminController@getData')->where('alias', '.+');
            });
        });
    });
```

You can see all examples in [Examples directory](./examples).

Mixins
------

[](#mixins)

```
+myResourceMixin(ControllerName, Alias = myResource):
  GET / as ${Alias}.list: ${ControllerName}@list
  /{id ~ \d+} as .${Alias}.element:
    GET / as .show: ${ControllerName}@show
    POST / as .update: ${ControllerName}@update
    PUT / as .create: ${ControllerName}@create
    DELETE / as .delete: ${ControllerName}@destroy

/entity as entityResource:
  +: myResourceMixin(MyEntityController, myEntity)
```

Regular Expressions presets
===========================

[](#regular-expressions-presets)

You can create predefined names for RegExps that using in uri params. It's simple to do. See the example below:

```
~hex: '[a-f0-9]+'
~urlAlias: '[A-Z-]+'

# Note: all regexes must be quoted because yaml-parser recognizes [...] as array
```

And if you want to use it in route you can write as:

```
GET /entity/{id ~hex} as entity: EntityController@show
```

Please note that there is no space. It's important. If you placed a space char there, the value will passed as plain regex `/numeric/`

Yaroute has few prefedined aliases:

- **numeric**: `\d+`
- **hex**: `[\da-fA-F]+`
- **alias**: `[\w-]+`
- **boolean**: `[01]`

Generating YAML
===============

[](#generating-yaml)

You can also generate new YAML document (based on registered routes in app) with `$ php artisan yaroute:generate`. It will be printed to stdout so you can pipe it to needed file, e.g.:

`$ php artisan yaroute:generate > routes/api.yaml`

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2150362?v=4)[Serabass](/maintainers/Serabass)[@Serabass](https://github.com/Serabass)

---

Top Contributors

[![Serabass](https://avatars.githubusercontent.com/u/2150362?v=4)](https://github.com/Serabass "Serabass (7 commits)")

### Embed Badge

![Health badge](/badges/serabass-yaroute/health.svg)

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

PHPackages © 2026

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