New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

marekmiklusek/laravel-starter-kit-livewire

A Laravel livewire starter kit with code quality tools pre-configured.
31 1
Install
composer require marekmiklusek/laravel-starter-kit-livewire
Latest Version:v1.7.5
PHP:^8.5
Laravel:13
Older releases:12
License:MIT
Last Updated:Nov 24, 2026
Links: GitHub  ·  Packagist
Maintainer: marekmiklusek

🚀 Laravel Livewire Starter Kit

Laravel's official Livewire starter kit enhanced with development workflow tools, code quality standards, and additional developer experience improvements.

📦 Bundled Packages

Beyond Laravel's default Livewire stack, this kit ships pre-configured with:

📋 Requirements

  • PHP: see the php constraint in composer.json
  • Composer
  • Node.js & NPM
  • MySQL (or your preferred database)

🚀 Quick Start

[!NOTE]

  • In config/database.php, 'engine' => 'InnoDB', is used as the default for both mysql and mariadb connections.
  • In config/essentials.php, models are unguarded by default via Unguard::class => true. This allows mass assignment without explicitly defining $fillable properties. You can change this setting if you prefer to use guarded models.

📦 Installation

Create a new Laravel Livewire project:

composer create-project marekmiklusek/laravel-starter-kit-livewire --prefer-dist app-name

Run the automated setup script:

composer setup

This command will:

  1. Install PHP dependencies via Composer
  2. Create .env file from .env.example (if not exists)
  3. Create .env.production file from .env.example (if not exists)
  4. Generate application key
  5. Run database migrations
  6. Install NPM dependencies
  7. Build frontend assets

⚙️ Additional Setup

🔧 Environment Configuration

After running composer setup, configure your .env file with your database credentials:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
🌐 Browser Testing Setup (Optional)

If you plan to use Pest's browser testing capabilities, install Playwright:

npm install playwright
npx playwright install

This installs the necessary browser binaries for running browser tests.

🌍 Localization

The starter kit ships with English (en) and Czech (cs) translations. Translation files live in the lang/ directory:

lang/
├── en.json              # UI strings (English)
├── cs.json              # UI strings (Czech)
├── en/
│   ├── auth.php         # Authentication messages
│   ├── passwords.php    # Password reset messages
│   ├── pagination.php   # Pagination labels
│   └── validation.php   # Validation messages
└── cs/
    ├── auth.php
    ├── passwords.php
    ├── pagination.php
    └── validation.php

Switch the active language by setting APP_LOCALE in your .env file:

APP_LOCALE=cs
APP_FALLBACK_LOCALE=en

To add another language, create a new lang/{locale}.json for UI strings and a matching lang/{locale}/ directory for the framework files.

👤 Creating Users

Users are created from the CLI:

php artisan user:create

The command prompts for name and email, then generates a random password and prints it once. Created users have their email already verified.

🔑 Two-Factor Authentication

Two-factor authentication (TOTP) is enabled in config/fortify.php. To disable it, remove Features::twoFactorAuthentication() from the features array:

  • The /settings/two-factor route is not registered and returns 404
  • The "Two-Factor Auth" link in the settings sidebar is hidden automatically
  • Fortify's /two-factor-* endpoints (challenge, enable, confirm, recovery codes) are not registered
  • With the required second factor, users have to add a passkey instead

The TwoFactorAuthenticatable trait stays on the User model. It is inert without the feature registered, and removing it would break factories that fill 2FA columns.

The 2FA setup (QR code, setup key, verification code) is rendered inline on the settings page, not in a modal, so browser authenticator extensions can scan the QR code.

🗝️ Passkeys

Users can register passkeys (Windows Hello, Touch ID, a phone or a security key) under Settings → Passkeys, sign in with them on the login page and use them to confirm their password. Passkeys are provided by Fortify (Features::passkeys() in config/fortify.php) and stored in the passkeys table.

WebAuthn only works in a secure context, so serve the site over HTTPS and point APP_URL at it:

herd secure your-app
APP_URL=https://your-app.test

Over plain HTTP the passkey buttons stay hidden and the settings page shows "Passkeys are not supported in this browser."

[!TIP] On Windows, if the browser offers only 1Password, a phone or a security key, enable Settings → Accounts → Passkeys → Advanced options → Save passkeys to this Windows device to get Windows Hello (fingerprint, face, PIN).

🛡️ Required Second Factor

Every user must set up two-factor authentication or a passkey before using the app. The EnsureSecondFactorIsEnrolled middleware (appended to the web group and registered as Livewire persistent middleware) redirects users who have neither confirmed 2FA nor a passkey to the 2FA settings page, or to the passkeys page when 2FA is disabled. Logout, password confirmation, email verification and the 2FA and passkey routes stay reachable.

At least one factor must stay active. Users can switch between 2FA and passkeys, but disabling 2FA without a passkey or removing the last passkey without 2FA sends them back to the setup. The check lives in RequiresSecondFactorEnrollmentQuery.

Turn the requirement off in config/fortify.php:

'second_factor_required' => false,

Logging in with a password also confirms the password for the session, so the 2FA settings page does not ask for it again right after login.

💾 Database Backups

The starter kit ships with marekmiklusek/database-backup for automated MySQL backups. The config is already published to config/database-backup.php, so no vendor:publish is needed.

Backups are stored locally on the local disk in storage/app/private/database-backups, and old backups are cleaned up automatically after 14 days.

A daily backup is already scheduled in routes/console.php:

Schedule::command('db-backup:run')
    ->dailyAt('02:00')
    ->onOneServer()
    ->runInBackground();

Run it manually at any time:

php artisan db-backup:run      # create a backup
php artisan db-backup:cleanup  # delete backups older than the retention period

Adjust the disk, directory, filename pattern, retention period, and mail notifications in config/database-backup.php. To back up to Google Drive instead of (or alongside) local storage, add a google disk to config/filesystems.php and set storage.disk. See the package README for the full Google Drive setup guide.

📢 Slack Error Notifications

The starter kit ships with marekmiklusek/laravel-slack-errors, which sends unhandled exceptions to a Slack channel through an incoming webhook. No changes to bootstrap/app.php or the exception handler are needed.

Create an incoming webhook for your Slack app, choose the channel, and add the URL to .env (the keys are already present in .env.example):

SLACK_ERRORS_ENABLED=true             # default, set to false to disable notifications entirely
SLACK_ERRORS_WEBHOOK_URL=your_webhook_url
SLACK_ERRORS_ENVIRONMENTS=production  # comma-separated list, wildcards allowed

Send a test message to verify the webhook (it ignores the environment filter):

php artisan slack-errors:test

To change the mention, throttling, or ignored exceptions, publish the config to config/slack-errors.php:

php artisan vendor:publish --tag=slack-errors-config

[!TIP] Nothing is sent while SLACK_ERRORS_WEBHOOK_URL is empty, and only the environments listed in SLACK_ERRORS_ENVIRONMENTS report, so local development stays quiet. Exceptions in your app's dontReport are never sent.

🚀 Production Environment

The setup script automatically creates a .env.production file. Configure it with production-specific settings:

# Edit .env.production with your production settings

Configure production environment variables:

  • Set APP_ENV=production
  • Set APP_DEBUG=false
  • Configure production database credentials
  • Set secure APP_KEY (generated during setup)
  • Configure mail, cache, queue, and session drivers
  • Set proper logging channels

💻 Development

🖥️ Running the Development Server

Start all development services concurrently:

composer dev

This starts:

  • Laravel development server (port 8000) - Your Livewire application
  • Queue listener - Background job processing
  • Log viewer (Pail) - Real-time log monitoring
  • Vite dev server - Hot Module Replacement for CSS/JS

Your Livewire application will be available at http://localhost:8000 🎉

🏛️ Architecture

The kit enforces a small set of architecture rules. They are written down for AI agents in .ai/guidelines/architecture.md and enforced by PHPStan and Pest, so a violation fails composer test.

🧱 Layers

Layer Location Create with
Actions (writes and business logic) app/Actions php artisan make:action "{Name}" --no-interaction
Queries (reads) app/Queries php artisan make:query "{Name}" --no-interaction
DTOs (structured data between layers) app/Dtos php artisan make:dto "{Name}" --no-interaction

Livewire components, commands, jobs and listeners only validate input, call actions and queries, and return a response.

🔎 PHPStan Rules

Custom rules live in tests/PHPStan/Rules and run with composer test:types. Every error message starts with the rule ID and says how to fix it.

ID Rule
Q1 Query classes only read data
T1 No side effects (HTTP, API clients, jobs, events, mail, notifications) inside DB::transaction()
D1 Actions and queries never take or return associative arrays, API clients in app/Services never return them
C1 Cache, rate limiter and signed URL expirations are Carbon expressions (now()->addMinutes(15))
A1 Database writes only in actions
R1 Database reads only in query classes
P1 A private method duplicated across actions is extracted into its own action

Two rules are configurable in phpstan.neon:

services:
    -
        class: Tests\PHPStan\Rules\SideEffectCallDetector
        arguments:
            sideEffectClasses:
                - App\Services\ShoptetClient
    -
        class: Tests\PHPStan\Rules\ArrayInsteadOfDtoRule
        arguments:
            apiResponseNamespaces:
                - App\Services
  • sideEffectClasses: your API clients, so T1 also catches their calls inside a transaction
  • apiResponseNamespaces: where your API clients live, so D1 checks their return values

✅ Conventions

Checked by tests/Unit/ArchTest.php and tests/Unit/CodingConventionsTest.php:

  • Tests mirror app/: app/Livewire/Settings/Profile.php is tested in tests/Feature/Livewire/Settings/ProfileTest.php, and every action, query, command, controller, middleware, Livewire component, job, listener, service and model has its own test file
  • Objects are named after their class (CreateUser $createUser), dates by meaning (CarbonInterface $orderedAt)
  • app/Actions, app/Dtos and app/Enums are flat, ambiguous class names (Config, Item, Service, ...) are not allowed
  • Validation rules always have both min: and max:
  • No mocks in tests and no single-letter variables

Money is never a float. Amounts are stored as integers in the smallest unit (cents) and formatted as decimals only for display.

🤖 AI Guidelines

The kit uses Laravel Boost to generate CLAUDE.md (Claude Code) and AGENTS.md (Codex) from one source:

  • .ai/guidelines/architecture.md: the kit's architecture rules with the same IDs as the PHPStan errors
  • .ai/guidelines/php/core.blade.php: overrides Boost's PHP guideline (no descriptive comments, type-only PHPDoc)

Kit rules take precedence over conflicting advice in Boost skills. Never edit CLAUDE.md or AGENTS.md directly. Change the guidelines and regenerate them:

php artisan boost:update

boost:update also runs automatically after composer update.

🔍 Code Quality

🧹 Linting & Formatting

Fix code style issues:

composer lint

This runs:

  • Rector (PHP refactoring)
  • Laravel Pint (PHP formatting)
  • Prettier (frontend formatting)

🧪 Testing

Run the full test suite:

composer test

This includes:

  • Type coverage (100% minimum)
  • Code coverage (100% required)
  • Unit and feature tests (Pest)
  • Code style validation
  • Static analysis (PHPStan)

🌐 Browser Testing

This starter kit includes Pest with browser testing capabilities. Create browser tests in tests/Browser/:

it('displays the login page', function () {
    $page = visit('/login');

    $page->assertSee('Log in')
        ->assertNoJavascriptErrors();
});

🧪 Testing Livewire Components

Test your Livewire components with Pest's built-in Livewire testing:

use Livewire\Livewire;

it('can update user profile', function () {
    $user = User::factory()->create();
    
    Livewire::actingAs($user)
        ->test(\App\Livewire\Settings\Profile::class)
        ->set('name', 'New Name')
        ->call('save')
        ->assertHasNoErrors()
        ->assertDispatched('profile-updated');
        
    expect($user->fresh()->name)->toBe('New Name');
});

📜 Available Scripts

🎼 Composer Scripts

  • composer setup - Initial project setup
  • composer dev - Run all development services
  • composer lint - Fix code style issues
  • composer test - Run full test suite
  • composer test:unit - Run Pest tests only
  • composer test:types - Run PHPStan analysis
  • composer test:type-coverage - Check type coverage
  • composer test:lint - Validate code style
  • composer update:requirements - Update all dependencies

📦 NPM Scripts

  • npm run dev - Start Vite dev server
  • npm run build - Build for production
  • npm run lint - Format frontend code
  • npm run test:lint - Check frontend code style

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Packages

simovative/zeus

A Post-Redirect-Get specialised framework for PHP

122,996 7
laravel/framework

The Laravel Framework.

633,434,998 35,124
laravel/laravel

The skeleton application for the Laravel framework.

66,677,375 85,393
laravel-zero/foundation

This is a mirror from illuminate/foundation.

1,965,973 34

Version History

Version Released PHP Laravel License
v1.7.5 ^8.5 ^13.42.0 MIT
v1.7.4 ^8.5 ^13.42.0 MIT
v1.7.3 ^8.5 ^13.42.0 MIT
v1.7.2 ^8.5 ^13.42.0 MIT
v1.7.1 ^8.5 ^13.42.0 MIT