β All skills
Php Developer
Use when building modern web applications with PHP 8.3+ and Laravel 11, featuring Eloquent ORM, queues, and middleware.
About this skill
Use when building modern web applications with PHP 8.3+ and Laravel 11, featuring Eloquent ORM, queues, and middleware.
SKILL.md
php-developer.SKILL.mdPlace it in your Syntic skills folder. For Syntic Code, install in your local skills directory, review the contents and run it in a controlled environment first.
---
name: Php Developer
description: Use when building modern web applications with PHP 8.3+ and Laravel 11, featuring Eloquent ORM, queues, and middleware.
category: Languages
version: 1.0.0
tools: []
---
# PHP 8.3+ & Laravel 11 Development
Build modern, production-ready web applications using PHP 8.3+ strict types and Laravel 11 framework patterns.
## Core Principles
- Add `declare(strict_types=1)` to every file; use typed properties, return types, union types
- Follow Laravel conventions for routing, middleware, request lifecycle
- Always eager-load Eloquent relationships; paginate results; avoid N+1 queries
- Use Composer for dependencies; pin versions; run `composer audit` regularly
## PHP 8.3+ Features
- Use `readonly` classes for DTOs and value objects; all properties implicitly readonly
- Use `BackedEnum` for database-storable type-safe values: `enum Status: string { case Active = 'active'; }`
- Use named arguments: `createUser(name: $name, role: Role::Admin)`
- Use `match` expressions instead of `switch` with strict comparison
- Use first-class callable syntax: `array_map($this->transform(...), $items)`
## Laravel 11 Architecture
```
app/Http/Controllers/ # Thin controllers, single responsibility
app/Models/ # Eloquent models with scopes, casts, relations
app/Services/ # Business logic
app/Actions/ # Single-purpose action classes
app/Enums/ # PHP 8.1+ backed enums
app/Jobs/ # Queued background jobs
```
## Eloquent Best Practices
- Define relationships explicitly: `hasMany`, `belongsTo`, `belongsToMany`, `morphMany`
- Use `with()` for eager loading: `User::with(['posts', 'posts.comments'])->get()`
- Use query scopes: `scopeActive`, `scopeCreatedAfter`
- Use attribute casting: `'metadata' => 'array'`, `'status' => Status::class`
- Use `chunk()` or `lazy()` for large datasets
- Use `upsert()` for bulk insert-or-update; `updateOrCreate()` for single records
## API & Queues
- Use API Resources for response transformation
- Use Form Requests for validation; return `$request->validated()`
- Use Sanctum for token-based API authentication
- Use Laravel Horizon with Redis for queue management
- Make jobs idempotent; use `ShouldBeUnique` to prevent duplicates
- Set `$tries`, `$backoff`, `$timeout` on every job class
## Testing
- Use Pest PHP for expressive test syntax
- Use `RefreshDatabase` trait; use `LazilyRefreshDatabase` for speed
- Use model factories: `Factory::new()->create()`
- Use `Http::fake()` for mocking HTTP; `Queue::fake()` for job assertions
- Test validation, authorization, error paths, not just success cases
## Before Completing
- Run `php artisan test` or `./vendor/bin/pest`
- Run `./vendor/bin/phpstan analyse` at level 8
- Run `./vendor/bin/pint` for code formatting
- Run `php artisan route:list` to verify routes
Install
Syntic App
- 1Create a dedicated folder for this skill in your local skills library.
- 2Place SKILL.md into that folder.
- 3Restart Syntic and invoke this skill on matching tasks.
Syntic Code (CLI)
- 1Save SKILL.md in your local Syntic Code skills directory.
- 2Keep related files in the same skill folder.
- 3Run in a safe environment and validate outputs.