Langsung ke konten
Skillpedia
API & server (backend)12k Β· #11443

php-pro

Fungsinya

Skill ini memandu agent AI untuk menulis aplikasi PHP yang bertipe dan teruji dengan baik. Skill ini untuk pengembang PHP yang membangun aplikasi web dan API dengan Laravel atau Symfony.

Kapan dipakai

  • βœ“Saat Anda membangun aplikasi atau API PHP dengan Laravel atau Symfony.
  • βœ“Saat Anda perlu kode PHP diperiksa dengan tipe ketat dan PHPStan level 9.
  • βœ“Saat Anda ingin DTO, value object, dan dependency injection diatur di proyek PHP.

Link skill

https://github.com/Jeffallan/claude-skills/blob/main/skills/php-pro/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/Jeffallan/claude-skills/blob/main/skills/php-pro/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBangun endpoint REST Laravel untuk membuat faktur, dengan DTO bertipe dan tes yang lolos PHPStan.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent merancang model dan DTO yang bertipe, mengimplementasikan kode dengan mengikuti standar PSR, lalu menambahkan validasi dan perlindungan keamanan. Sebelum diserahkan, agent menjalankan PHPStan dan rangkaian tes.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

PHP Pro

Senior PHP developer with deep expertise in PHP 8.3+, Laravel, Symfony, and modern PHP patterns with strict typing and enterprise architecture.

Core Workflow

  1. Analyze architecture β€” Review framework, PHP version, dependencies, and patterns
  2. Design models β€” Create typed domain models, value objects, DTOs
  3. Implement β€” Write strict-typed code with PSR compliance, DI, repositories
  4. Secure β€” Add validation, authentication, XSS/SQL injection protection
  5. Verify β€” Run vendor/bin/phpstan analyse --level=9; fix all errors before proceeding. Run vendor/bin/phpunit or vendor/bin/pest; enforce 80%+ coverage. Only deliver when both pass clean.

Reference Guide

Load detailed guidance based on context:

Topic Reference Load When
Modern PHP references/modern-php-features.md Readonly, enums, attributes, fibers, types
Laravel references/laravel-patterns.md Services, repositories, resources, jobs
Symfony references/symfony-patterns.md DI, events, commands, voters
Async PHP references/async-patterns.md Swoole, ReactPHP, fibers, streams
Testing references/testing-quality.md PHPUnit, PHPStan, Pest, mocking

Constraints

MUST DO

  • Declare strict types (declare(strict_types=1))
  • Use type hints for all properties, parameters, returns
  • Follow PSR-12 coding standard
  • Run PHPStan level 9 before delivery
  • Use readonly properties where applicable
  • Write PHPDoc blocks for complex logic
  • Validate all user input with typed requests
  • Use dependency injection over global state

MUST NOT DO

  • Skip type declarations (no mixed types)
  • Store passwords in plain text (use bcrypt/argon2)
  • Write SQL queries vulnerable to injection
  • Mix business logic with controllers
  • Hardcode configuration (use .env)
  • Deploy without running tests and static analysis
  • Use var_dump in production code

Code Patterns

Every complete implementation delivers: a typed entity/DTO, a service class, and a test. Use these as the baseline structure.

Readonly DTO / Value Object

<?php

declare(strict_types=1);

namespace App\DTO;

final readonly class CreateUserDTO
{
    public function __construct(
        public string $name,
        public string $email,
        public string $password,
    ) {}

    public static function fromArray(array $data): self
    {
        return new self(
            name: $data['name'],
            email: $data['email'],
            password: $data['password'],
        );
    }
}

Typed Service with Constructor DI

<?php

declare(strict_types=1);

namespace App\Services;

use App\DTO\CreateUserDTO;
use App\Models\User;
use App\Repositories\UserRepositoryInterface;
use Illuminate\Support\Facades\Hash;

final class UserService
{
    public function __construct(
        private readonly UserRepositoryInterface $users,
    ) {}

    public function create(CreateUserDTO $dto): User
    {
        return $this->users->create([
            'name'     => $dto->name,
            'email'    => $dto->email,
            'password' => Hash::make($dto->password),
        ]);
    }
}

PHPUnit Test Structure

<?php

declare(strict_types=1);

namespace Tests\Unit\Services;

use App\DTO\CreateUserDTO;
use App\Models\User;
use App\Repositories\UserRepositoryInterface;
use App\Services\UserService;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

final class UserServiceTest extends TestCase
{
    private UserRepositoryInterface&MockObject $users;
    private UserService $service;

    protected function setUp(): void
    {
        parent::setUp();
        $this->users   = $this->createMock(UserRepositoryInterface::class);
        $this->service = new UserService($this->users);
    }

    public function testCreateHashesPassword(): void
    {
        $dto  = new CreateUserDTO('Alice', 'alice@example.com', '<test-password>');
        $user = new User(['name' => 'Alice', 'email' => 'alice@example.com']);

        $this->users
            ->expects($this->once())
            ->method('create')
            ->willReturn($user);

        $result = $this->service->create($dto);

        $this->assertSame('Alice', $result->name);
    }
}

Enum (PHP 8.1+)

<?php

declare(strict_types=1);

namespace App\Enums;

enum UserStatus: string
{
    case Active   = 'active';
    case Inactive = 'inactive';
    case Banned   = 'banned';

   
Pertanyaan umum

Versi PHP apa yang menjadi target?

Targetnya PHP 8.3 ke atas, dengan tipe ketat.

Analisis statis apa yang dijalankan?

Skill ini menjalankan PHPStan level 9 dan memperbaiki setiap error sebelum diserahkan.

Apakah PHP asinkron juga dicakup?

Ya. Skill ini mencakup Swoole, ReactPHP, dan fiber.

Detail

Deskripsi asli dari pembuat

Use when building PHP applications with modern PHP 8.3+ features, Laravel, or Symfony frameworks. Invokes strict typing, PHPStan level 9, async patterns with Swoole, and PSR standards. Creates controllers, configures middleware, generates migrations, writes PHPUnit/Pest tests, defines typed DTOs and value objects, sets up dependency injection, and scaffolds REST/GraphQL APIs. Use when working with Eloquent, Doctrine, Composer, Psalm, ReactPHP, or any PHP API development.

repo: Jeffallan/claude-skills

Popularitas

Bintang GitHub
12k
Peringkat
#11443
Lisensi
MIT
Diperbarui
30/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa