PHPackages                             thepublicgood/routine - 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. [Framework](/categories/framework)
4. /
5. thepublicgood/routine

ActiveLibrary[Framework](/categories/framework)

thepublicgood/routine
=====================

Class-based routing for Laravel

058PHP

Since Aug 19Pushed 3y ago2 watchersCompare

[ Source](https://github.com/tpg/routine)[ Packagist](https://packagist.org/packages/thepublicgood/routine)[ RSS](/packages/thepublicgood-routine/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Routine
=======

[](#routine)

A really basic solution to class-based routing for Laravel. It's very simplistic and probably needs a lot of work. I only wrote this for myself and isn't really intended for the wider world.

I don't intend to provide much support for this package and will likely only update it when I need to. I'm not even sure I'll continue to use it. It's more of an experiment really.

But if you really want to use it, then by all means, install it with Composer:

```
composer require thepublicgood/routine
```

Once installed, publish the config file with:

```
php ./artisan vendor:publish --provider="TPG\Routine\RoutineServiceProvider"
```

This will place a `routine.php` file in your config directory. Now create a new empty class and extend the `TPG\Routine\RouteRegistrar` class. Create new methods that are prefixed with `map` and suffixed with `Routes`. Routine will call each method and map the defined routes.

Each map method must accept an instance of `Illuminate\Routing\Router`:

```
use App\Http\Controllers\SessionController;
use Illuminuate\Routing\Router;
use TPG\Routine\RouteRegistrar;

class AuthRoutes extends RouteRegistrar
{
    protected function mapWebRoutes(Router $router): void
    {
        $router->middleware(['guest'])->group(function (Router $router) {

            $router->get('/login', [SessionController::class, 'create'])->name('login');
            $router->post('/login', [SessionController::class, 'store']);

        });

        $router->middleware(['auth'])->post('/logout', [SessionController:class, 'destroy'])->name('logout');
    }
}
```

By default, Routine will set default middleware depending on the name of the method. You can find these defaults in the `routine.php` config file. For example, the method `mapWebRoutes` will automatically use the middleware set as the `web`default. The method `mapApiRoutes` will automatically use the middleware set as the `api` default. This means you could create a default called `ajax` for example, and the method `mapAjaxRoutes` will automatically set those middleware.

Middleware Contracts
--------------------

[](#middleware-contracts)

In addition, it can be useful to apply middleware for an entire route file. For example, if you need to specify that a set of routes need authentication. You can do this by implementing the `TPG\Routing\Contracts\RequiresAuthentication`interface:

```
use Illuminuate\Routing\Router;
use TPG\Routine\Contracts\RequiresAuthentication;
use TPG\Routine\RouteRegistrar;

class DashboardRoutes extends RouteRegistrar implements RequiresAuthentication
{
    // ...
}
```

Routine includes a `RequiresAuthentication`, `RequiresSanctumAuthentication` and a `SignedRoute` contract by default. If you add your own, ensure that you add them to the `routine.php` config file.

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity25

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://www.gravatar.com/avatar/89ea2dc12cd0a934de60705f8cfe47397095d842121b7d5f545dc9d1cee554ec?d=identicon)[warrickbayman](/maintainers/warrickbayman)

---

Top Contributors

[![warrickbayman](https://avatars.githubusercontent.com/u/856840?v=4)](https://github.com/warrickbayman "warrickbayman (6 commits)")

### Embed Badge

![Health badge](/badges/thepublicgood-routine/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M829](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[pinguo/php-msf

Pinguo Micro Service Framework For PHP

1.7k4.2k](/packages/pinguo-php-msf)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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