# Magic Starter Laravel

**Ship the app backend without the controllers.**

The Laravel backend of Magic Starter: sign-in, two-factor, teams, notifications and billing as Sanctum-token JSON routes. Each feature is a toggle and each action can be replaced.

Runs on: PHP 8.2+, Laravel 12.32+, Laravel 13

## The API behind your app, already built.

Sign-in, teams, notifications and billing ship as JSON routes behind feature toggles. Turn on what the app needs and replace any action with your own.

### Sign-in, every way

Login and registration answer with a Sanctum token and the user, by email, by phone or both. Social, guest and phone OTP sign-in sit behind feature toggles.

- `two-factor-authentication` adds TOTP with a QR code, recovery codes and the sign-in challenge
- Phone OTP ships a `LogOtpProvider` that only writes to the log: bind `SendsOtpCodes` first

[Read the docs about Sign-in, every way](https://anilcancakir.com/magic-starter-laravel/docs/basics/authentication.md)

### Teams and invitations

Create teams, invite by email, change member roles and switch the current team. With `restorable-teams` a deleted team can be restored for a window.

- With `teams` picked, the installer publishes the `Team`, `TeamUser` and `TeamInvitation` models and a `TeamPolicy`
- Schedule `magic-starter:purge-trashed-teams` yourself: the package registers it and does not schedule it

[Read the docs about Teams and invitations](https://anilcancakir.com/magic-starter-laravel/docs/basics/teams.md)

### Subscriptions on two rails

Stripe through Laravel Cashier and the App Store or Google Play through RevenueCat, kept as one entitlement on the user or the team.

- Never publish `cashier-migrations`: they target `users` with integer keys whatever `billing.billable` says
- `billing:manifest` prints what the vendors must hold and `billing:doctor` checks it

[Read the docs about Subscriptions on two rails](https://anilcancakir.com/magic-starter-laravel/docs/basics/billing.md)

### Notifications and push

Database notifications with an unread count and a per-type, per-channel preference matrix. With `onesignal` on, push goes through OneSignal.

- OneSignal accepts a mismatched external id and delivers to nobody: keep the prefix equal to the client's
- Mail moves to OneSignal one mail class at a time, through a router transport

[Read the docs about Notifications and push](https://anilcancakir.com/magic-starter-laravel/docs/basics/notifications.md)

### An optional admin panel on Filament

`magic-starter:filament:install` adds a panel with resources for users, teams, billing, audits, releases and support, each shown only while its feature is on.

- List staff in `MAGIC_STARTER_ADMIN_EMAILS`: an empty list admits nobody
- Every write goes through the same action contract the API calls

```php
use Filament\Models\Contracts\FilamentUser;
use AnilcanCakir\MagicStarter\Filament\Concerns\AuthorizesAdminPanel;

class User extends Authenticatable implements FilamentUser
{
    use AuthorizesAdminPanel;
}
```

[Read the docs about An optional admin panel on Filament](https://anilcancakir.com/magic-starter-laravel/docs/basics/admin-panel.md)

### Every action replaceable

Controllers stay thin and inject a contract from `Contracts\`. Bind your own class and the API and the admin panel both change.

- `vendor:publish --tag=magic-starter-stubs` copies skeletons that throw until you implement them
- Models resolve at runtime through `MagicStarter::userModel()`, `teamModel()` and `billableModel()`

```php
// app/Providers/AppServiceProvider.php
use AnilcanCakir\MagicStarter\Contracts\CreatesUsers;
use App\Actions\MagicStarter\CreateUser; // your class

public function register(): void
{
    $this->app->bind(CreatesUsers::class, CreateUser::class);
}
```

[Read the docs about Every action replaceable](https://anilcancakir.com/magic-starter-laravel/docs/architecture/action-contracts.md)

## Questions, answered.

What people ask before they add Magic Starter Laravel to a Laravel app.

### What is Magic Starter Laravel?

Magic Starter Laravel is a Laravel package that serves authentication, two-factor, social sign-in, profile, teams, notifications, billing and a support desk as Sanctum-token JSON routes. It is the backend of the Flutter starter `magic_starter`.

### How do I install Magic Starter Laravel?

Run `composer require anilcancakir/magic-starter-laravel`, then `php artisan magic-starter:install` and `php artisan migrate`. The installer asks which features to enable, picks UUID or integer keys from your `users` table and publishes the config, the migrations and a `User` model.

### What does Magic Starter Laravel require?

PHP 8.2 or later with `ext-gd` and `ext-exif`, and Laravel 12.32 or later, or Laravel 13. The optional admin panel needs Filament `^4.13.3` or `^5.8.3`.

### Do I need the Flutter app to use it?

The package does not depend on it: the routes are JSON over Sanctum tokens. `magic_starter` is the Flutter client that calls them one to one, so a route changed here should change there too.

### How do I turn a feature on?

Add its key to the `features` array of `config/magic-starter.php`, or choose it in `magic-starter:install`. A feature that is off registers none of its routes, commands or scheduled tasks, so its endpoints answer 404.

### Can I change what a route does?

Yes. Controllers inject a contract from `Contracts\`, and the service provider binds each one to a default under `Actions\`. Bind your own class to the contract in `AppServiceProvider::register()` and the API and the admin panel both use it.

### Does Magic Starter Laravel work with AI coding agents?

Yes. Laravel Boost installs the `magic-starter-development` skill the package ships, and its docs are available as `llms.txt` and over MCP.

### Is Magic Starter Laravel open source?

Yes. Magic Starter Laravel is open source under the MIT license.

## Add it in seconds

```bash
composer require anilcancakir/magic-starter-laravel
```

Then run `php artisan magic-starter:install` and `php artisan migrate`. Or add it to `composer.json`:

```json
{
    "require": {
        "anilcancakir/magic-starter-laravel": "^1.0.3"
    }
}
```

Or give your AI agent this prompt:

```text
Read https://anilcancakir.com/magic-starter-laravel/docs/llms.txt and install the Magic Starter Laravel package in this project.
```

## Docs

### Getting Started

- [Installation](https://anilcancakir.com/magic-starter-laravel/docs/getting-started/installation.md)
- [Configuration](https://anilcancakir.com/magic-starter-laravel/docs/getting-started/configuration.md)
- [Migrating from fluttersdk/magic-starter-laravel](https://anilcancakir.com/magic-starter-laravel/docs/getting-started/migrating-from-fluttersdk.md)

### The Basics

- [Authentication](https://anilcancakir.com/magic-starter-laravel/docs/basics/authentication.md)
- [Two-Factor Authentication](https://anilcancakir.com/magic-starter-laravel/docs/basics/two-factor-authentication.md)
- [Social Login](https://anilcancakir.com/magic-starter-laravel/docs/basics/social-login.md)
- [Sign-in Handoff](https://anilcancakir.com/magic-starter-laravel/docs/basics/sign-in-handoff.md)
- [Profile Management](https://anilcancakir.com/magic-starter-laravel/docs/basics/profile.md)
- [Account Deletion](https://anilcancakir.com/magic-starter-laravel/docs/basics/account-deletion.md)
- [Teams](https://anilcancakir.com/magic-starter-laravel/docs/basics/teams.md)
- [Notifications](https://anilcancakir.com/magic-starter-laravel/docs/basics/notifications.md)
- [Billing](https://anilcancakir.com/magic-starter-laravel/docs/basics/billing.md)
- [Support Desk](https://anilcancakir.com/magic-starter-laravel/docs/basics/support.md)
- [Support AI Tools](https://anilcancakir.com/magic-starter-laravel/docs/basics/support-tools.md)
- [Support Proposals](https://anilcancakir.com/magic-starter-laravel/docs/basics/support-proposals.md)
- [Admin Panel](https://anilcancakir.com/magic-starter-laravel/docs/basics/admin-panel.md)
- [Audit Trail](https://anilcancakir.com/magic-starter-laravel/docs/basics/audit.md)
- [Releases](https://anilcancakir.com/magic-starter-laravel/docs/basics/releases.md)

### Architecture

- [Action-Contracts Architecture](https://anilcancakir.com/magic-starter-laravel/docs/architecture/action-contracts.md)
- [Models Architecture](https://anilcancakir.com/magic-starter-laravel/docs/architecture/models.md)
- [Service Provider](https://anilcancakir.com/magic-starter-laravel/docs/architecture/service-provider.md)

### Guides

- [Mail on OneSignal](https://anilcancakir.com/magic-starter-laravel/docs/guides/mail-onesignal.md)
- [AI Prompt Overrides](https://anilcancakir.com/magic-starter-laravel/docs/guides/ai-prompts.md)
- [AI Run Log](https://anilcancakir.com/magic-starter-laravel/docs/guides/ai-runs.md)
