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 1mo 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 5% 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/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

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

1.9k36.7M256](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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