laravel-starter-kit-livewire maintained by marekmiklusek
🚀 Laravel Livewire Starter Kit
Laravel's official Livewire starter kit enhanced with development workflow tools, code quality standards, and additional developer experience improvements from laravel-starter-kit. ✨
📋 Requirements
- PHP >= 8.4.0
- Composer
- Node.js & NPM
- MySQL (or your preferred database)
🚀 Quick Start
[!NOTE]
- In
config/database.php,'engine' => 'InnoDB',is used as the default for bothmysqlandmariadbconnections.- In
config/essentials.php, models are unguarded by default viaUnguard::class => true. This allows mass assignment without explicitly defining$fillableproperties. 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:
- Install PHP dependencies via Composer
- Create
.envfile from.env.example(if not exists) - Create
.env.productionfile from.env.example(if not exists) - Generate application key
- Run database migrations
- Install NPM dependencies
- 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.
🔐 Enable / Disable Registration
User self-registration is controlled by a single switch via the FORTIFY_REGISTRATION_ENABLED env variable:
FORTIFY_REGISTRATION_ENABLED=true # default — registration is open
FORTIFY_REGISTRATION_ENABLED=false # disable registration
When set to false:
- The
/registerroute is not registered and returns 404 - The "Don't have an account? Sign up" link on the login page is hidden automatically
The flag is also exposed as config()->boolean('fortify.registration_enabled') if you need to read it elsewhere in the application.
🔑 Enable / Disable Two-Factor Authentication
Two-factor authentication is controlled by a single switch via the FORTIFY_2FA_ENABLED env variable:
FORTIFY_2FA_ENABLED=true # default — 2FA is available
FORTIFY_2FA_ENABLED=false # disable 2FA
When set to false:
- The
/settings/two-factorroute 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
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. Tests always run with 2FA enabled regardless of .env (forced via phpunit.xml), so the 100% coverage gate is not affected by toggling this flag locally.
🚀 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 🎉
🔍 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 4 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 setupcomposer dev- Run all development servicescomposer lint- Fix code style issuescomposer test- Run full test suitecomposer test:unit- Run Pest tests onlycomposer test:types- Run PHPStan analysiscomposer test:type-coverage- Check type coveragecomposer test:lint- Validate code stylecomposer update:requirements- Update all dependencies
📦 NPM Scripts
npm run dev- Start Vite dev servernpm run build- Build for productionnpm run lint- Format frontend codenpm run test:lint- Check frontend code style
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.