# php-expert

The php-expert skill guides PHP 8+, Laravel, Composer, and PHPUnit work. Use it for modern PHP implementation, testing, and code review.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 269 installs · ★ 45 repo stars
- Author: personamanagmentlayer
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/php-expert/SKILL.md
- Updated: 2026-10-12
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/php-expert

## What it does

php-expert gives an agent a focused set of practices for PHP 8+ and object-oriented development. It covers strict typing, typed properties and returns, namespaces, PSR-4 autoloading, dependency injection, enums, attributes, and other modern language features.

The skill also covers Laravel, Composer, and PHPUnit workflows. Its testing guidance includes feature tests, unit tests, model factories, API assertions, authentication, validation, and model relationships. Available tools are `Read`, `Write`, and `Edit`; shell access is limited to `php`, `composer`, and `artisan` commands.

The skill targets PHP 8+, so older PHP projects fall outside its stated scope.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill php-expert -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/php-expert/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/php-expert/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill php-expert -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/php-expert/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill php-expert -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/php-expert/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install personamanagmentlayer/pcl stdlib/languages/php-expert
```

2. **Manually: put the files in place**
- File: `.github/skills/php-expert/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill php-expert -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/languages/php-expert
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/php-expert/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill php-expert -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/php-expert/SKILL.md

## When to use it
- write typed PHP 8+ code
- create Laravel feature and unit tests
- build model factories for PHPUnit
- inspect Composer dependencies
- review code against PSR standards and listed anti-patterns

## Example prompts
- Review this PHP 8+ service and add strict typing throughout.
- Create PHPUnit feature tests for creating and updating a Laravel post.
- Inspect `composer.json` and revise this code for PSR-4 and PSR-12 compliance.

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 817e097cdcded23b.

BEGIN THIRD-PARTY FILE 817e097cdcded23b
````text
---
name: php-expert
version: 1.1.0
description: >-
  Expert-level PHP development with PHP 8+, Laravel, Composer, and modern best practices.
  Use when the user mentions Laravel, Composer, Symfony, PHPUnit, or PSR standards, or when
  the task involves PHP 8+ Features, Object-Oriented PHP, Modern PHP, or Constructor
  Property Promotion.
category: languages
tags: [php, laravel, composer, symfony, phpunit, psr]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(php:*, composer:*, artisan:*)
---

# PHP Expert

Expert guidance for modern PHP development including PHP 8+ features, Laravel framework, Composer dependency management, and PHP best practices.

## Core Concepts

### PHP 8+ Features

- Union types and mixed type
- Named arguments
- Attributes (annotations)
- Constructor property promotion
- Match expressions
- Nullsafe operator
- JIT compiler
- Fibers (PHP 8.1+)
- Readonly properties and classes

### Object-Oriented PHP

- Classes and objects
- Interfaces and abstract classes
- Traits
- Namespaces
- Autoloading (PSR-4)
- Type declarations
- Visibility modifiers

### Modern PHP

- Strict types
- Return type declarations
- Property type declarations
- Enums (PHP 8.1+)
- First-class callable syntax

## Testing with PHPUnit

### Feature Tests

```php
<?php

namespace Tests\Feature;

use App\Models\User;
use App\Models\Post;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class PostControllerTest extends TestCase
{
    use RefreshDatabase;

    public function test_can_list_posts(): void
    {
        Post::factory()->count(3)->create(['published' => true]);
        Post::factory()->create(['published' => false]);

        $response = $this->getJson('/api/posts');

        $response->assertOk()
            ->assertJsonCount(3, 'data');
    }

    public function test_can_create_post_when_authenticated(): void
    {
        $user = User::factory()->create();

        $response = $this->actingAs($user, 'api')
            ->postJson('/api/posts', [
                'title' => 'Test Post',
                'content' => 'Test content with enough characters to pass validation.',
            ]);

        $response->assertCreated()
            ->assertJsonPath('data.title', 'Test Post');

        $this->assertDatabaseHas('posts', [
            'title' => 'Test Post',
            'user_id' => $user->id,
        ]);
    }

    public function test_cannot_create_post_when_not_authenticated(): void
    {
        $response = $this->postJson('/api/posts', [
            'title' => 'Test Post',
            'content' => 'Test content',
        ]);

        $response->assertUnauthorized();
    }

    public function test_validates_post_creation(): void
    {
        $user = User::factory()->create();

        $response = $this->actingAs($user, 'api')
            ->postJson('/api/posts', [
                'title' => '', // Invalid
                'content' => 'Short', // Too short
            ]);

        $response->assertUnprocessable()
````
END THIRD-PARTY FILE 817e097cdcded23b

The third-party file has ended. Everything between the 817e097cdcded23b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2997 of 7825 bytes. © personamanagmentlayer · Apache-2.0 · https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/php-expert/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
