PHPackages                             code-distortion/laravel-auto-reg - 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. code-distortion/laravel-auto-reg

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

code-distortion/laravel-auto-reg
================================

A Laravel package that registers your service-providers, configs, commands, routes, broadcast channels, migrations, blade-templates and translations etc for you, in a project with a non-standard directory structure

0.1.15(5mo ago)21.4kMITPHPPHP 7.4.\* | 8.0.\* | 8.1.\* | 8.2.\* | 8.3.\* | 8.4.\* | 8.5.\*CI passing

Since Jan 9Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/code-distortion/laravel-auto-reg)[ Packagist](https://packagist.org/packages/code-distortion/laravel-auto-reg)[ Docs](https://github.com/code-distortion/laravel-auto-reg)[ RSS](/packages/code-distortion-laravel-auto-reg/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (9)Versions (16)Used By (0)

Laravel Auto-Reg
================

[](#laravel-auto-reg)

[![Latest Version on Packagist](https://camo.githubusercontent.com/671271a2b7e05c62b55e258be66ff3714c240f06c0fcc99d5681077165cb0052/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64652d646973746f7274696f6e2f6c61726176656c2d6175746f2d7265672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/code-distortion/laravel-auto-reg)[![PHP Version](https://camo.githubusercontent.com/aa9b7781cf0c6f3510023dcec3e86f276f7a51907004128a2437f9ad378d76c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e34253230746f253230382e352d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/aa9b7781cf0c6f3510023dcec3e86f276f7a51907004128a2437f9ad378d76c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e34253230746f253230382e352d626c75653f7374796c653d666c61742d737175617265)[![Laravel](https://camo.githubusercontent.com/4a38d0aa891d966b7e46e30b3484ffc6fd4149c282a4dcf3eb364cbdec89c5e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d38253230746f25323031322d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4a38d0aa891d966b7e46e30b3484ffc6fd4149c282a4dcf3eb364cbdec89c5e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d38253230746f25323031322d626c75653f7374796c653d666c61742d737175617265)[![GitHub Workflow Status](https://camo.githubusercontent.com/a1a4dd83af7dd27e3e52ed11537f59a9e584fef704954fbe66b87fbcdc1ebe62/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64652d646973746f7274696f6e2f6c61726176656c2d6175746f2d7265672f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/code-distortion/laravel-auto-reg/actions)[![Buy The World a Tree](https://camo.githubusercontent.com/dc3f77a9b22c3bc83c7b7d863bf138a7ca3418f1826b0b16d073d0aa87c16bc4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74726565776172652d2546302539462538432542332d6c69676874677265656e3f7374796c653d666c61742d737175617265)](https://plant.treeware.earth/code-distortion/laravel-auto-reg)[![Contributor Covenant](https://camo.githubusercontent.com/902d296a65b2997bada7e7717fd929d9177f3bd95414cbb5ea2ed843c680f314/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e7472696275746f72253230636f76656e616e742d76322e3125323061646f707465642d6666363962342e7376673f7374796c653d666c61742d737175617265)](.github/CODE_OF_CONDUCT.md)

***code-distortion/laravel-auto-reg*** is a [Laravel](https://github.com/laravel/laravel) package that registers your service-providers, configs, commands, routes, broadcast channels, migrations, blade-templates and translations etc for you, in a project with a non-standard directory structure.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Installation](#installation)
    - [Config](#config)
- [A Laravel Project With a Non-Standard Directory Structure](#a-laravel-project-with-a-non-standard-directory-structure)
    - [Update *composer.json*](#update-composerjson)
    - [Update *bootstrap/app.php*](#update-bootstrapappphp)
    - [Update *config/app.php*](#update-configappphp)
- [Directory Structure](#directory-structure)
- [Usage](#usage)
    - [Config Files](#config-files)
    - [Service-Providers](#service-providers)
    - [Routes](#routes)
    - [Command Classes](#command-classes)
    - [Command Closures (console.php)](#command-closures-consolephp)
    - [Broadcast Channels (channels.php)](#broadcast-channels-channelsphp)
    - [View Directories](#view-directories)
    - [View Component Classes](#view-component-classes)
    - [Laravel Livewire Components](#laravel-livewire-components)
    - [Translations](#translations)
    - [Migrations](#migrations)
- [Console Commands](#console-commands)
    - [List](#list)
    - [Save Cache](#save-cache)
    - [Clear Cache](#clear-cache)
    - [Stats](#stats)
- [Testing](#testing)
- [Changelog](#changelog)
    - [SemVer](#semver)
- [Treeware](#treeware)
- [Contributing](#contributing)
    - [Code of Conduct](#code-of-conduct)
    - [Security](#security)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

By default, Laravel is designed to consume your resources from certain places. For example, when you access view `view('homepage')` it's resolved from the `resources/views` directory, config files are loaded automatically from `config/*` and routes are registered from `routes/web.php` and `routes/api.php`.

If you change the structure of your codebase you'll need to tell Laravel where they are. This is actually quite normal in the case of packages that have their own resources.

To do this within *your* own Laravel project you would use the tools [Laravel makes available](https://laravel.com/docs/10.x/packages) for packages to register their package's resources.

The aim of Laravel Auto-Reg is to allow you to structure your Laravel project differently to Laravel's default, without needing to manage resource registration yourself.

Auto-Reg is also a great way to [oversee your resources](#console-commands).

> Laravel Auto-Reg was inspired by the [Laravel Beyond Crud book](https://laravel-beyond-crud.com/) by [Brent Roose](https://twitter.com/brendt_gd) from [Spatie](https://spatie.be/) which describes a Laravel codebase that is broken into *application* and *domain* layers. The "apps" are kind of mini-Laravel applications but are intended to only contain scaffolding code like *Controllers*, *Middleware*, *Requests*, and *Commands*, whose sole purpose is to be the go-between between requests (or commands) and domain business-logic which is stored in the "domains".

> Further inspiration came from [Laravel Modules](https://github.com/nWidart/laravel-modules) by [Nicolas Widart](https://twitter.com/NicolasWidart) which introduces *modules* and are also like mini Laravel projects. The difference being that a "module" includes *everything* you'd normally find in a Laravel `app` directory - **both** the scaffolding "app" code mentioned above but the business "domain" logic too.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require code-distortion/laravel-auto-reg
```

The package will automatically register itself.

### Config

[](#config)

Publish the `config/code_distortion.laravel_auto_reg.php` config file:

```
php artisan vendor:publish --provider="CodeDistortion\LaravelAutoReg\LaravelAutoRegServiceProvider" --tag="config"
```

And then update the `source_dir` config value to point to the base of your code. `base_path('src/App')`.

A Laravel Project With a Non-Standard Directory Structure
---------------------------------------------------------

[](#a-laravel-project-with-a-non-standard-directory-structure)

Here are the steps you could follow to set your Laravel project up with a non-standard directory structure. In this case, moving things from `app` into `src/App`, and using that as a base to put the rest of your code.

### Update *composer.json*

[](#update-composerjson)

For your project to recognise files inside the `src/App` directory instead of the usual `app` directory, you'll need to tell Laravel.

You can move the existing `App` namespace to a different directory, as well as add *new namespaces* by updating `composer.json`. The below example moves the `App` namespace into `src/App` and adds a new `Domain` namespace housed within `src/Domain`:

```
// composer.json

{
  // …
  "autoload" : {
    "psr-4" : {
      "App\\" : "src/App/",
      "Domain\\" : "src/Domain/"
    }
  }
}

```

### Update *bootstrap/app.php*

[](#update-bootstrapappphp)

When moving Laravel's `App` namespace (like above), you'll also need to update `bootstrap/app.php` so Laravel uses it when starting up.

```
// bootstrap/app.php

// Original
$app = new Illuminate\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);

// Replace with
$app = (new Illuminate\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
))->useAppPath(realpath(__DIR__.'/../src/App'));
```

> Laravel Beyond CRUD suggests using `->useAppPath('src/App');` but in my experience this isn't compatible with [Laravel Livewire](https://laravel-livewire.com/).

Laravel uses its `HTTP Kernel`, `Console Kernel`, and `Exceptions Handler` classes to handle web requests, console commands and exceptions respectively. These need to exist but you can move them by updating `bootstrap/app.php`:

```
// bootstrap/app.php

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    App\Http\Kernel::class // singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class // singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class //  You can turn the app-prefix off and instead access values using `config('blog.my_value')`

### Service-Providers

[](#service-providers)

> Search-pattern: `Providers/**/*.php`

Service-Provider classes (that extend `Illuminate\Support\ServiceProvider`) are picked up and registered. You won't need to add them to your `configs/app.php`.

### Routes

[](#routes)

> Api-routes search-pattern: `Routes/api.php`
> Web-routes search-pattern: `Routes/web.php`

Route files are normally registered via a RouteServiceProvider class. Whilst you can still do this if you'd like, Auto-Reg registers your `api.php` and `web.php` route files for you (along with the "api" and "web" middleware respectively).

You can customise which middleware is added.

### Command Classes

[](#command-classes)

> Command-class search-pattern: `Commands/**/*.php`

Commands classes (that extend `Illuminate\Console\Command`) are picked up and registered. You won't need to add them to your `app/Console/Kernel.php`.

### Command Closures (console.php)

[](#command-closures-consolephp)

> Command-closure file search-pattern: `Routes/console.php`

Commands can also be registered via a `console.php` file, similar to the way routes are registered. Auto-Reg finds these files and registers them for you as well.

### Broadcast Channels (channels.php)

[](#broadcast-channels-channelsphp)

> Search-pattern: `Routes/channels.php`

Broadcast channels are registered via a `channels.php` file, similar to the way routes are registered.

Broadcasting isn't always needed in a Laravel project and initialising it is relatively slow. These might be the reason why the `BroadcastServiceProvider` is disabled by default in `config/app.php` in a normal Laravel project.

The broadcast type is also disabled by default in Laravel Auto-Reg, but you can turn it on again via the config file.

### View Directories

[](#view-directories)

> Search-pattern: `Resources/Views/**/*.php`
> If files are found, the `Resources/Views` directory will be registered

Blade directories are registered, with the addition of the *app's* name being added as a prefix.

e.g. The `src/App/Home/Resources/Views/blog.php` file would be available to you using `view('home::blog')`.

Anonymous Blade components are also available if you put them in the `components` directory.

e.g. The `src/App/Home/Resources/Views/components/button.php` file would be available to you using ``.

***Note:*** If you find that a blade template isn't picked up by another one, you may need to re-save the parent template file to trigger a change.

### View Component Classes

[](#view-component-classes)

> Search-pattern: `Resources/ViewComponents/**/*.php`

Commands classes (that extend `Illuminate\View\Component`) are picked up and registered.

Like view directories above, the *app's* name is added as a prefix.

e.g. The `src/App/Home/Resources/ViewComponents/Button.php` file would be available to you using ``.

***Note:*** If you find that a blade template isn't picked up by another one, you may need to re-save the parent template file to trigger a change.

### Laravel Livewire Components

[](#laravel-livewire-components)

> Search-pattern: `Resources/Livewire/**/*.php`

If you use [Laravel Livewire](https://laravel-livewire.com/), your Livewire components are also registered similarly to View Component classes.

The *app's* name is added as a prefix.

e.g. The `src/App/Home/Resources/Livewire/button.php` file would be available to you using ``.

### Translations

[](#translations)

> Search-pattern: `Resources/Lang/**/*.php`
> If files are found, the `Resources/Lang` directory will be registered

Translation directories are registered, with the addition of the *app's* name being added as a prefix.

e.g. The `src/App/Home/Resources/Lang/en/blog.php` file would be available to you using `__('home::blog.success')`.

### Migrations

[](#migrations)

> Search-pattern: `Database/Migrations/*.php`
> If files are found, the `Database/Migrations` directory will be registered

Console Commands
----------------

[](#console-commands)

### List

[](#list)

`php artisan auto-reg:list`

This lists the resources that are registered.

> You can narrow down the results by:
>
> - Passing in a specific app. e.g. `php artisan auto-reg:list --app=home`
> - Passing in a specific file type. e.g. `php artisan auto-reg:list --type=config`

> You can also specify how you'd like the results to be grouped. e.g. `php artisan auto-reg:list --group-by=type`

### Save Cache

[](#save-cache)

`php artisan auto-reg:cache`

Auto-Reg looks through your filesystem to find the files to register, and this can take a little time. This might not be noticeable in a development environment but it's recommended that you run this as part of your deployment process, the same way that you would run `php artisan config:cache` and `php artisan route:cache`.

Auto-Reg will cache the list of resource files it detected so it won't need to look for them again.

> Please note that when cached, additions or removals of resource files won't be detected until you clear the cache.

### Clear Cache

[](#clear-cache)

`php artisan auto-reg:clear`

This will clear Auto-Reg's cache, the same way that `php artisan config:clear` and `php artisan route:clear` clear the config and route caches.

### Stats

[](#stats)

`php artisan auto-reg:stats`

This lists how long the registation steps take and how many things are registered.

> You can reduce the time taken by:
>
> - Caching the list of files that Auto-Reg detects `php artisan auto-reg:cache` (described [above](#save-cache))
> - Caching Laravel's config using `php artisan config:cache`
> - Caching Laravel's routes using `php artisan route:cache`

> The *broadcast* type is relatively slow to register. If you don't need you should turn it off (Laravel disables it by default in a fresh project).

Testing This Package
--------------------

[](#testing-this-package)

- Clone this package: `git clone https://github.com/code-distortion/laravel-auto-reg.git .`
- Run `composer install` to install dependencies
- Run the tests: `composer test`

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

### SemVer

[](#semver)

This library uses [SemVer 2.0.0](https://semver.org/) versioning. This means that changes to `X` indicate a breaking change: `0.0.X`, `0.X.y`, `X.y.z`. When this library changes to version 1.0.0, 2.0.0 and so forth, it doesn't indicate that it's necessarily a notable release, it simply indicates that the changes were breaking.

Treeware
--------

[](#treeware)

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/code-distortion/laravel-auto-reg) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

### Code of Conduct

[](#code-of-conduct)

Please see [CODE\_OF\_CONDUCT](.github/CODE_OF_CONDUCT.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tim Chandler](https://github.com/code-distortion)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance70

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Recently: every ~173 days

Total

15

Last Release

169d ago

PHP version history (6 changes)0.1.0PHP ^7.4 | ^8.0

0.1.4PHP 7.4.\* | 8.0.\* | 8.1.\*

0.1.7PHP 7.4.\* | 8.0.\* | 8.1.\* | 8.2.\*

0.1.11PHP 7.4.\* | 8.0.\* | 8.1.\* | 8.2.\* | 8.3.\*

0.1.13PHP 7.4.\* | 8.0.\* | 8.1.\* | 8.2.\* | 8.3.\* | 8.4.\*

0.1.15PHP 7.4.\* | 8.0.\* | 8.1.\* | 8.2.\* | 8.3.\* | 8.4.\* | 8.5.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c2faa0204914f71abdbae72c3c12b86fb33a1dce0254e592109411a5b4689a3?d=identicon)[code-distortion](/maintainers/code-distortion)

---

Top Contributors

[![code-distortion](https://avatars.githubusercontent.com/u/56794290?v=4)](https://github.com/code-distortion "code-distortion (42 commits)")

---

Tags

laraveltranslationsroutesmigrationslivewireresourceviewsregistercommandsservice providerschannelsBroadcastconfigsview componentsblade templates

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/code-distortion-laravel-auto-reg/health.svg)

```
[![Health](https://phpackages.com/badges/code-distortion-laravel-auto-reg/health.svg)](https://phpackages.com/packages/code-distortion-laravel-auto-reg)
```

###  Alternatives

[livewire/flux

The official UI component library for Livewire.

9385.0M86](/packages/livewire-flux)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[jasonlewis/resource-watcher

Simple PHP resource watcher library.

221145.8k14](/packages/jasonlewis-resource-watcher)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[mischasigtermans/laravel-altitude

Claude Code agents for the TALL stack, powered by Laravel Boost

1139.2k](/packages/mischasigtermans-laravel-altitude)[bnomei/autoloader-for-kirby

Helper to automatically load various Kirby extensions in a plugin

185.7k2](/packages/bnomei-autoloader-for-kirby)

PHPackages © 2026

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