> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dezerx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Helpers

> Base classes, events, middleware and commands you can lean on instead of writing your own.

![Your module on top of base classes, jobs, events and support classes](https://mintcdn.com/dezerx/dVNBM3sq4VCh7CKa/public/extensions/helpers/top.webp?fit=max\&auto=format\&n=dVNBM3sq4VCh7CKa\&q=85\&s=ae2d7d5963ff161b47e4956862a367d2)

## Base classes

> [accordion] Classes and interfaces to extend
>
> | Class | Namespace | For |
> | - | - | - |
> | `BaseModuleServiceProvider` | `App\Modules` | Shared module bootstrapping |
> | `BaseModuleRouteServiceProvider` | `App\Modules` | Route wiring and middleware aliases |
> | `ServiceModuleServiceProvider` | `App\Modules` | Service provider base |
> | `GatewayModuleServiceProvider` | `App\Services\Payment\Modules` | Gateway provider base |
> | `OAuthProviderServiceProvider` | `App\Modules` | Login provider base |
> | `RegistrarModuleServiceProvider` | `App\Modules` | Registrar provider base |
> | `AddonModuleServiceProvider` | `App\Modules` | Addon provider base |
> | `EmptyGatewayEventServiceProvider` | `App\Services\Payment\Modules` | Event provider for gateways with no listeners |
> | `BaseRenewService` | `App\Services` | Service renewal |
> | `BaseCancelService` | `App\Services` | Service cancellation |
> | `BasePaymentService` | `App\Services\Payment` | Gateway payment service |
> | `ModulePaymentController` | `App\Http\Controllers\Payment` | Gateway payment routes |
> | `ModuleSettingsController` | `App\Http\Controllers\Payment` | Declarative admin settings for any module type |
> | `AbstractRegistrar` | `App\Domains` | Registrar base, throws `unsupported` for optional methods |

> [accordion] Support classes
>
> | Class | Use |
> | - | - |
> | `App\Support\RuntimeSnapshot` | `remember($key, $resolver)` and `bump()`. Memo shared by every worker |
> | `App\Support\ModuleStatuses` | `all()` and `enabled($name)` |
> | `App\Support\ModulePath` | Module paths and group folders |
> | `App\Modules\ModuleContracts` | The extension point spec that drives `module:doctor` |
> | `App\Modules\ModulePermissionRegistry` | Merges module permissions into core |
> | `App\Modules\OAuthProviderRegistry` | Enabled login providers |
> | `App\Services\ServiceControlLoader` | Loads `ServiceControlsService` |
> | `App\Services\Payment\PaymentGatewayManager` | Gateway registry. `flushAvailableCache()` |

## Core events

All are post-events. None can veto or change the action.

> [accordion] The 27 events in app/Events
>
> | Event | Fires when |
> | - | - |
> | `UserRegistered` | A user registers |
> | `ServiceCheckoutInitiated` | Checkout starts |
> | `ServicePaymentCompleted` | Payment for a service succeeds |
> | `ServiceProvisioned` | A service has been created by its module |
> | `InvoicePaid`, `StandaloneInvoicePaid` | An invoice is marked paid |
> | `ServiceRenewalInitiated`, `ServiceRenewed` | Renewal starts, completes |
> | `ServiceUpgradeCompleted`, `ServiceDowngradeCompleted` | A plan change completes |
> | `ServiceConfigurationChanged` | Configurable options changed |
> | `AddonPurchased` | An addon is bought |
> | `ServiceSuspended`, `ServiceUnsuspended` | Suspension state changes |
> | `ServiceTerminated`, `ServiceCancelled` | A service ends |
> | `ServiceWarned` | An overdue warning is issued |
> | `ServiceAutoRenewalToggled` | Auto renew switched |
> | `OrderRequiresManualApproval` | An order is held for review |
> | `BankWireProofSubmitted` | Bank transfer proof uploaded |
> | `TicketCreated`, `TicketMessageSent`, `TicketStatusChanged`, `TicketTransferred` | Support tickets |
> | `DiscordLinked`, `DiscordUnlinked` | Discord link state |
> | `CartItemAdded` | A product is added to the cart |

## Middleware

> [accordion] Ready-made middleware
>
> | Middleware | Use |
> | - | - |
> | `AdminMiddleware` | Admin only |
> | `PermissionMiddleware` | Permission check from route defaults or the merged map |
> | `AdminReauthMiddleware` | Password reconfirmation for sensitive admin actions |
> | `AdminAuditLogMiddleware` | Logs admin changes |
> | `ModuleServiceAuditLogMiddleware` | Logs service panel actions |
> | `CheckServicePermissions` | Sub-user permissions on `/service/{serviceId}/...` |
> | `ServiceRoutesMiddleware` | Routes the request to the right service module |
> | `CheckUserSuspension`, `CheckIpBan`, `Require2FA` | Account and access checks |

## Commands

```bash theme={null}
php artisan make:module {Name} --type={service|gateway|provider|registrar|addon} [--webhook] [--enable]
php artisan module:doctor [{Name}...] [--json] [--strict]
php artisan module:list
php artisan module:enable {Name}
php artisan module:disable {Name}
php artisan module:migrate {Name}
php artisan octane:reload
php artisan queue:restart
```

`module:doctor` exits non-zero on errors, so it works in CI. `--strict` also fails on warnings and `--json` prints machine readable output.

## Octane at a glance

| Do not | Do |
| - | - |
| `exit()`, `die()`, `$response->send()` | `throw new HttpResponseException($response)` |
| Read the user or request in `boot()` | Do per-request work in middleware |
| `Inertia::share()` in a provider | `Inertia::share()` in a middleware |
| Request state in a static or `singleton()` | `scoped()` bindings |
| A static array memo of database rows | `RuntimeSnapshot::remember()` |
| `Event::listen()` in a request | Register once in your provider |

More in [Enabling and Octane](https://docs.dezerx.com/extensions/tutorials/enabling.md#code-that-is-safe-in-a-worker).

## Things that need a core change

| What | Where |
| - | - |
| A sidebar link without seeding a row | `SidebarLink` table, through the admin UI |
| Replacing a string-resolved contract with a typed one | `ModuleContracts` plus the call site |
| Caching a public module page for guests | Add the route name to `config/page_cache.php` |

Everything else, including admin routes, permissions, login provider branding and settings pages, is declared from the module itself.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.