PHPackages                             northwestern-sysdev/chassis - 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. northwestern-sysdev/chassis

ActiveLibrary[Framework](/categories/framework)

northwestern-sysdev/chassis
===========================

Shared Laravel infrastructure for audited models, idempotent seeders, API error handling, configuration validation, and more.

v1.0.0(1mo ago)01.3k↓100%[1 PRs](https://github.com/NIT-Administrative-Systems/chassis/pulls)1MITPHPPHP ^8.3CI passing

Since Apr 23Pushed 2w ago2 watchersCompare

[ Source](https://github.com/NIT-Administrative-Systems/chassis)[ Packagist](https://packagist.org/packages/northwestern-sysdev/chassis)[ Docs](https://github.com/NIT-Administrative-Systems/chassis)[ RSS](/packages/northwestern-sysdev-chassis/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (15)Versions (8)Used By (1)

Chassis
=======

[](#chassis)

[![PHP Version](https://camo.githubusercontent.com/ac2ada860614f6eeaf52dc1daf22de80255bd66f385140a15bf6dc9d492c1a5a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332b2d3737374242343f7374796c653d666c6174266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net)[![Laravel Version](https://camo.githubusercontent.com/f52ba288e4fd9f86ff07679763033689dc1f7bb2d3449b7552c1fafc364c059e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e7825323025374325323031332e782d4630353334303f7374796c653d666c6174266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://laravel.com)[![Packagist Version](https://camo.githubusercontent.com/3993e80e89633371ef3ec2a900d15ce69aa33cb56db3bd96026ef995b64a8657/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f7274687765737465726e2d7379736465762f636861737369733f7374796c653d666c6174266c6162656c3d5061636b6167697374)](https://packagist.org/packages/northwestern-sysdev/chassis)[![License](https://camo.githubusercontent.com/6336e39f2162220495f69916695a3aed617a071b69cf525a72a72412f9b16b11/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d3232433535453f7374796c653d666c6174)](LICENSE)

Shared Laravel infrastructure for application-level framework concerns like audited models, idempotent seeders, API error handling, configuration validation, snapshot tooling, and migration helpers. Chassis serves as the core framework layer for Northwestern University's [Laravel Starter](https://laravel-starter.entapp.northwestern.edu/), while remaining usable in other Laravel applications that want these features without copying boilerplate between projects.

Features
--------

[](#features)

AreaIncludedEloquent foundations`BaseModel`, `Auditable`, `HasAutomaticOrdering`, `#[AutomaticallyOrdered]`Seeding`IdempotentSeeder`, `#[AutoSeed]`, dependency resolution, orphan cleanup helpersAPI infrastructure`ProblemDetails`, `ProblemDetailsRenderer`, token auth middleware, request loggingEnvironment controls`EnvironmentLockdown`, `EnsureFeatureEnabled`Validation`#[ValidatesConfig]`, `ConfigValidator`, `php artisan config:validate`Database tooling`db:rebuild`, `db:wake`, schema-aware snapshot commandsApp migration`php artisan chassis:migrate`, Rector namespace rewrite supportMisc utilities`@datetime`, `DateTimeFormatter`, `ValidIpOrCidrRule`, `SentryExceptionHandler`Installation
------------

[](#installation)

```
composer require northwestern-sysdev/chassis
```

Quick Start
-----------

[](#quick-start)

The fastest way to adopt Chassis is to use the parts that remove the most boilerplate first.

### 1. Start new models from `BaseModel`

[](#1-start-new-models-from-basemodel)

```
use Northwestern\SysDev\Chassis\Models\BaseModel;

class Project extends BaseModel
{
    //
}
```

`BaseModel` extends Eloquent's `Model` and wires in audit logging plus attribute-driven automatic ordering.

### 2. Make seeders rerunnable

[](#2-make-seeders-rerunnable)

```
use Northwestern\SysDev\Chassis\Attributes\AutoSeed;
use Northwestern\SysDev\Chassis\Seeding\IdempotentSeeder;

#[AutoSeed]
class RoleSeeder extends IdempotentSeeder
{
    protected string $model = Role::class;
    protected string $slugColumn = 'slug';

    public function data(): array
    {
        return [
            ['slug' => 'admin', 'label' => 'Admin'],
            ['slug' => 'editor', 'label' => 'Editor'],
        ];
    }
}
```

### 3. Register config validators

[](#3-register-config-validators)

```
use Northwestern\SysDev\Chassis\Attributes\ValidatesConfig;
use Northwestern\SysDev\Chassis\Contracts\ConfigValidator;

#[ValidatesConfig(description: 'Directory Search credentials')]
class DirectorySearchValidator implements ConfigValidator
{
    public function shouldRun(): bool { /* ... */ }
    public function validate(): bool { /* ... */ }
    public function successMessage(): string { /* ... */ }
    public function errorMessage(): string { /* ... */ }
    public function hints(): array { /* ... */ }
}
```

Then run:

```
php artisan config:validate
```

### 4. Return consistent API errors

[](#4-return-consistent-api-errors)

Subclass `ProblemDetailsRenderer` to keep Chassis' default exception mapping and layer in your domain-specific cases:

```
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Northwestern\SysDev\Chassis\Exceptions\ProblemDetailsRenderer;
use Northwestern\SysDev\Chassis\Http\Responses\ProblemDetails;
use Throwable;

class AppProblemDetailsRenderer extends ProblemDetailsRenderer
{
    protected function mapCustomExceptions(Throwable $e, Request $request): ?JsonResponse
    {
        return match (true) {
            $e instanceof TokenBudgetExceededException => tap(
                ProblemDetails::tooManyRequests(detail: $e->getMessage()),
                fn () => $this->setFailure('token-budget-exceeded'),
            ),
            default => null,
        };
    }
}
```

Core Features
-------------

[](#core-features)

### Models and Auditing

[](#models-and-auditing)

- `BaseModel` is the default model base for chassis-aware apps.
- `Auditable` enriches `owen-it/laravel-auditing` records with request context such as trace IDs, Livewire component names, and impersonator IDs when available.
- `#[AutomaticallyOrdered]` adds declarative default ordering, using `order_index asc, label asc` unless you override the columns and directions.
- `HasAutomaticOrdering` lets non-`BaseModel` classes opt into the same behavior.

See [Audit Logging](https://laravel-starter.entapp.northwestern.edu/features/audit-logging/) and [Framework Defaults: Eloquent behavior](https://laravel-starter.entapp.northwestern.edu/architecture/framework-defaults/#eloquent-behavior).

### Idempotent Seeding

[](#idempotent-seeding)

Chassis' seeding layer is built for repeated execution across local, CI, staging, and production environments.

- `#[AutoSeed]` marks a seeder for discovery.
- Dependencies are validated and executed in topological order.
- Rows are upserted by your declared slug column.
- Soft-deleted matches are restored instead of duplicated.
- Orphan cleanup is available when you opt in.

For more advanced cases, override `afterUpsert(Model $model, array $row)` and list any non-column keys in `$transient`. If your seeder cannot extend the base class cleanly, use the lower-level `PerformsIdempotentUpserts` and `CleansUpOrphans` concerns directly.

See [Idempotent Seeding](https://laravel-starter.entapp.northwestern.edu/architecture/idempotent-seeding/).

### API Infrastructure

[](#api-infrastructure)

- `ProblemDetails` builds RFC 9457 responses such as `unauthorized()`, `forbidden()`, `notFound()`, `unprocessableEntity()`, and `conflict()`.
- `ProblemDetailsRenderer` maps framework and infrastructure exceptions to RFC 9457 JSON for API and JSON-negotiated requests.
- `AuthenticatesAccessTokens` is an abstract middleware base for bearer token auth with hashing, IP allowlisting, expiration checks, and usage recording.
- `LogsApiRequests` records request outcome, timing, size, token, and trace metadata, and emits `X-Trace-Id` on responses.
- `EnvironmentLockdown` restricts non-production environments to authorized users.
- `EnsureFeatureEnabled` short-circuits routes behind config flags.
- `AccessTokenContract` defines the token model hooks the auth middleware relies on.

See [API](https://laravel-starter.entapp.northwestern.edu/features/api/) and [RFC 9457 defaults](https://laravel-starter.entapp.northwestern.edu/architecture/framework-defaults/#rfc-9457-problem-details-for-api).

### Configuration Validation

[](#configuration-validation)

`php artisan config:validate` discovers every class implementing `ConfigValidator` that is decorated with `#[ValidatesConfig]`. Validators run concurrently and report pass, fail, or skip states with remediation hints.

See [Command reference: config:validate](https://laravel-starter.entapp.northwestern.edu/reference/commands/#configvalidate).

### Database Snapshots

[](#database-snapshots)

Chassis wraps [`spatie/laravel-db-snapshots`](https://github.com/spatie/laravel-db-snapshots) with schema checksums so restores can detect drift between the snapshot's source schema and the current app state.

```
php artisan db:snapshot:create baseline
php artisan db:snapshot:list
php artisan db:snapshot:restore baseline
php artisan db:snapshot:info baseline
php artisan db:snapshot:delete baseline
```

Snapshot commands are registered only when `spatie/laravel-db-snapshots` is installed. They are intended for non-production use.

See [Database Snapshots](https://laravel-starter.entapp.northwestern.edu/features/database-snapshots/).

### Console Utilities

[](#console-utilities)

CommandPurpose`config:validate`Run all discovered `#[ValidatesConfig]` validators.`db:rebuild`Fresh migrate and seed, with cache and related cleanup.`db:seed:list`List discovered `#[AutoSeed]` seeders. Supports dependency output, Mermaid, and JSON.`db:wake`Retry database connection until a cold or sleeping database is available.`db:snapshot:create {name?}`Create a schema-tagged database snapshot.`db:snapshot:restore {name?}`Restore a snapshot and warn if the schema checksum has drifted.`db:snapshot:list`List saved snapshots.`db:snapshot:info {name}`Show snapshot metadata and schema checksum details.`db:snapshot:delete {name}`Delete a snapshot and its metadata.`restore-env-files`Restore local-only environment files after a clean checkout.`chassis:migrate`Migrate a pre-chassis starter app onto package namespaces and base classes.`RunsSteps` is also available if you want the same structured spinner + summary experience in your own multi-step Artisan commands.

Full command docs:

### Other Utilities

[](#other-utilities)

- `@datetime` renders timestamps in the authenticated user's timezone via the `DateTimeFormatter` service.
- `ValidIpOrCidrRule` validates IPv4, IPv6, and CIDR input.
- `SentryExceptionHandler` enriches Sentry reporting with user context when `sentry/sentry-laravel` is installed.
- `ApiRequestContext` centralizes request context keys shared across middleware, logging, and exception handling.
- `ApiRequestFailure` standardizes API failure labels, descriptions, and icons for UI consumption.

Optional Packages
-----------------

[](#optional-packages)

Some features stay opt-in so applications only install what they use.

PackageEnables[`spatie/laravel-db-snapshots`](https://github.com/spatie/laravel-db-snapshots)`db:snapshot:*` commands[`sentry/sentry-laravel`](https://github.com/getsentry/sentry-laravel)`SentryExceptionHandler`[`lab404/laravel-impersonate`](https://github.com/404labfr/laravel-impersonate)Impersonator tracking in audit recordsMigrating an Existing Starter App
---------------------------------

[](#migrating-an-existing-starter-app)

If your application was generated from the Northwestern Laravel Starter before Chassis existed, migrate it in one pass:

```
composer require northwestern-sysdev/chassis
php artisan chassis:migrate
```

The migration command is intentionally broad. It can:

- Rewrite extracted starter namespaces to package namespaces
- Remove legacy copied framework files now provided by Chassis
- Scaffold app-level subclasses where project-specific overrides still belong
- Rewrite middleware references in route files
- Replace old config validator patterns with `#[ValidatesConfig]`
- Remove app-level `@datetime` directive registration
- Convert rebuild command customizations into the new extension points
- Clean up PHPUnit exclusions related to extracted files

The command is idempotent. Re-running it is safe, and reviewing the diff before committing is still the right workflow.

If you want only the namespace rewrite behavior, `ChassisNamespaceRector` exposes the class rename map for custom Rector configs.

Development
-----------

[](#development)

```
composer install
composer test
composer analyse:php
composer format:php
composer rector
composer all
```

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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 ~0 days

Total

4

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d4678c8051de43c86bddf6aec2c570d07175ac1011296dd25b8e6e97a0af34b?d=identicon)[northwestern-sysdev](/maintainers/northwestern-sysdev)

---

Top Contributors

[![dxnter](https://avatars.githubusercontent.com/u/17434202?v=4)](https://github.com/dxnter "dxnter (27 commits)")

---

Tags

laravelnorthwestern

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/northwestern-sysdev-chassis/health.svg)

```
[![Health](https://phpackages.com/badges/northwestern-sysdev-chassis/health.svg)](https://phpackages.com/packages/northwestern-sysdev-chassis)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.1k2.2k](/packages/unopim-unopim)[laravel/octane

Supercharge your Laravel application's performance.

4.0k24.7M203](/packages/laravel-octane)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

18476.4k](/packages/lunarstorm-laravel-ddd)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3861.7k](/packages/codewithdennis-larament)

PHPackages © 2026

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