Laravel Boost Guidelines for NativePHP
Expert Laravel development assistant following Laravel maintainer-curated guidelines for the NativePHP application.
Core Technology Stack
This skill is optimized for:
**PHP 8.4.11** with constructor property promotion and type declarations**Laravel 10** with traditional Kernel-based architecture**Filament v3** for admin panels and CRUD interfaces**Livewire v3** for reactive components**Alpine.js v3** for client-side interactivity**Tailwind CSS v4** for styling**Pest/PHPUnit** for testingDevelopment Principles
1. Follow Existing Conventions
Inspect sibling files before creating new ones to match structure, naming, and approachUse descriptive variable and method names (e.g., `isRegisteredForDiscounts`, not `discount()`)Check for existing components to reuse before writing new onesStick to existing directory structure—don't create new base folders without approval2. Use Artisan Commands
Always use `php artisan make:*` commands to create new files (migrations, controllers, models, etc.)Pass `--no-interaction` to all Artisan commandsUse `make:class` for generic PHP classesFor models, create factories and seeders simultaneously3. Database & Eloquent Best Practices
Always use proper Eloquent relationship methods with return type hintsPrefer `Model::query()` over `DB::`Use eager loading to prevent N+1 query problemsUse Laravel's query builder only for very complex operationsFor APIs, use Eloquent API Resources and versioning4. Validation & Controllers
Always create Form Request classes for validation (never inline in controllers)Include both validation rules and custom error messagesCheck sibling Form Requests to match array or string-based validation style5. Configuration & Environment
Never use `env()` outside config filesAlways use `config('app.name')` instead of `env('APP_NAME')`Use named routes and the `route()` function for URL generationPHP Code Standards
Type Declarations
```php
// Always use explicit return types and type hints
protected function isAccessible(User $user, ?string $path = null): bool
{
// Implementation
}
```
Constructor Property Promotion
```php
// Use PHP 8 constructor property promotion
public function __construct(public GitHub $github) { }
```
Control Structures
```php
// Always use curly braces, even for single lines
if ($condition) {
doSomething();
}
```
Enums
```php
// Keys should be TitleCase
enum FavoritePerson: string {
case BestFriend = 'best_friend';
case Monthly = 'monthly';
}
```
Filament v3 Guidelines
Core Concepts
**Resources**: CRUD interfaces in `app/Filament/Resources/`**Resource Pages**: Auto-generated in `app/Filament/Resources/PostResource/Pages/`**Actions**: Buttons with modals and logic encapsulated**Forms**: Use `Forms\Components` namespace**Tables**: Use `Tables\Columns` namespace**Widgets**: Dashboard components for stats/chartsUsing Relationships
```php
Forms\Components\Select::make('user_id')
->label('Author')
->relationship('author')
->required(),
```
Artisan Commands
Use Filament-specific commands: `php artisan filament:*`Always pass `--no-interaction` flagUse `php artisan filament:optimize` for productionTesting Filament
```php
// Table test
livewire(ListUsers::class)
->assertCanSeeTableRecords($users)
->searchTable($users->first()->name)
->assertCanSeeTableRecords($users->take(1));
// Create resource test
livewire(CreateUser::class)
->fillForm([
'name' => 'Howdy',
'email' => '[email protected]',
])
->call('create')
->assertNotified()
->assertRedirect();
// Action test
livewire(EditInvoice::class, ['invoice' => $invoice])
->callAction('send');
```
Livewire Best Practices
Component Structure
Single root element requiredUse `wire:loading` and `wire:dirty` for UXAdd `wire:key` in loops:```blade
@foreach ($items as $item)
<div wire:key="item-{{ $item->id }}">
{{ $item->name }}
</div>
@endforeach
```
State Management
State lives on the serverAll requests hit Laravel backend—validate and authorizeUse lifecycle hooks: `mount()`, `updatedFoo()`Creating Components
```bash
php artisan make:livewire Posts\\CreatePost
```
Testing Standards
Feature Tests (Primary)
```php
// Use factories for model creation
$user = User::factory()->create();
// Check for custom factory states before manual setup
$admin = User::factory()->admin()->create();
// Use faker: $this->faker->word() or fake()->randomDigit()
```
Unit Tests
```bash
php artisan make:test --unit CalculatorTest
```
Key Principles
Feature tests over unit tests (most tests should be feature tests)Do not create verification scripts when tests existTests prove functionality—they're more important than tinker scriptsLaravel 10 Specifics
Architecture
Middleware: `app/Http/Middleware/`Service Providers: `app/Providers/`Middleware registration: `app/Http/Kernel.php`Exception handling: `app/Exceptions/Handler.php`Console commands: `app/Console/Kernel.php`Model Casts
```php
// Use array property, NOT casts() method
protected $casts = [
'metadata' => 'array',
'published_at' => 'datetime',
];
```
Common Issues & Solutions
Frontend Not Reflecting Changes
Ask user to run:
`npm run build``npm run dev``composer run dev`Vite Manifest Error
Solution: Run `npm run build` or ask user to start `npm run dev`
Documentation & Research
When you need specific Laravel ecosystem documentation:
1. Search for broad, topic-based queries: `['rate limiting', 'routing']`
2. Don't include package names in queries (already provided)
3. Use multiple queries for comprehensive results
4. Search before making code changes to ensure correct approach
Communication Style
Be concise—focus on important details, not obvious onesOnly create documentation files if explicitly requestedPHPDoc blocks over inline commentsComments only for very complex logicSecurity & Performance
Use queued jobs (`ShouldQueue`) for time-consuming operationsLeverage Laravel's authentication/authorization (gates, policies, Sanctum)All Livewire actions require validation and authorizationUse Laravel's query builder optimization techniques