用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/miles990/claude-software-skills --skill php命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Enterprise-grade repository analysis with arc42/C4 architecture documentation, technical debt quantification, security assessment, and multi-stakeholder reporting
Claude Code Plugin 開發、發布、安裝、更新與 Marketplace 管理完整指南
Flame Engine core fundamentals - components, input, collision, camera, animation, scenes
基于 SOC 职业分类
正在显示 SKILL.md
| name | php |
| description | Modern PHP programming patterns |
| domain | programming-languages |
| version | 1.0.0 |
| tags | ["php","laravel","composer","oop","traits"] |
| triggers | {"keywords":{"primary":["php","laravel","composer","symfony","wordpress"],"secondary":["eloquent","blade","artisan","phpunit","trait","doctrine"]},"context_boost":["web","backend","cms","api","legacy"],"context_penalty":["python","javascript","java","go"],"priority":"medium"} |
Modern PHP (7.4+/8.x) patterns including typed properties, attributes, and modern OOP features.
<?php
declare(strict_types=1);
// Typed properties (PHP 7.4+)
class User
{
public string $id;
public string $email;
public ?string $name = null;
public bool $active = true;
public array $roles = [];
public DateTimeImmutable $createdAt;
// Constructor promotion (PHP 8.0+)
public function __construct(
public readonly string $email,
public readonly string $name,
private string $password
) {
$this->id = uniqid();
$this->createdAt = new DateTimeImmutable();
}
}
// Union types (PHP 8.0+)
function process(string|int $value): string|int
{
return is_string($value) ? strtoupper($value) : $value * 2;
}
// Intersection types (PHP 8.1+)
function processIterable(Countable&Iterator $items): int
{
return count($items);
}
// Return types
function findUser(string $id): ?User
{
return $this->repository->find($id);
}
function getUsers(): array
{
return $this->repository->findAll();
}
// Never return type (PHP 8.1+)
function fail(string $message): never
{
throw new RuntimeException($message);
}
// Nullable types
function setName(?string $name): void
{
$this->name = $name;
}
<?php
use Attribute;
// Define attribute
#[Attribute(Attribute::TARGET_PROPERTY)]
class Column
{
public function __construct(
public string $name,
public string $type = 'string',
public bool $nullable = false
) {}
}
#[Attribute(Attribute::TARGET_METHOD)]
class Route
{
public function __construct(
public string $path,
public string $method = 'GET'
) {}
}
#[Attribute(Attribute::TARGET_CLASS)]
class Entity
{
public function __construct() {}
}
(: )
{
(: , : )
;
(: , : )
;
(: , : )
? ;
}
{
(: , : )
{
->userService->();
}
(: , : )
{
->userService->();
}
}
= (::);
= ->(::);
( ) {
= ->();
->table;
}
<?php
// Basic enum
enum Status
{
case Pending;
case Active;
case Inactive;
public function label(): string
{
return match ($this) {
self::Pending => 'Pending Review',
self::Active => 'Active',
self::Inactive => 'Inactive',
};
}
}
// Backed enum (with values)
enum Role: string
{
case Admin = 'admin';
case Moderator = 'moderator';
case User = 'user';
public function permissions(): array
{
return match ($this) {
self::Admin => ['read', 'write', 'delete', 'admin'],
self::Moderator => [, , ],
:: => [, ],
};
}
{
::();
}
{
::();
}
}
= ::;
->();
= ::;
->value;
= ::();
= ->();
<?php
// Trait definition
trait Timestampable
{
protected ?DateTimeImmutable $createdAt = null;
protected ?DateTimeImmutable $updatedAt = null;
public function getCreatedAt(): ?DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?DateTimeImmutable
{
return $this->updatedAt;
}
public function touch(): void
{
$now = new DateTimeImmutable();
$this->createdAt ??= $now;
$this->updatedAt = $now;
}
}
trait SoftDeletable
{
protected ?DateTimeImmutable $deletedAt = null;
public function delete(): void
{
$this->deletedAt = new ();
}
{
->deletedAt = ;
}
{
->deletedAt !== ;
}
}
{
;
;
{
->();
}
}
{
{
;
}
}
{
{
;
}
}
{
, {
:: ;
B:: helloFromB;
}
}
<?php
// Interface
interface Repository
{
public function find(string $id): ?object;
public function findAll(): array;
public function save(object $entity): void;
public function delete(string $id): void;
}
// Generic-style interface
interface Collection
{
public function add(mixed $item): void;
public function remove(mixed $item): bool;
public function contains(mixed $item): ;
;
;
}
{
{}
;
{
= ->pdo->(
);
->([ => ]);
= ->(PDO::);
? ->() : ;
}
{
= ->pdo->();
(
fn( ) => ->(),
->(PDO::)
);
}
}
{
{
::(, );
}
{
(
id: [],
email: [],
name: []
);
}
{
}
}
<?php
// Custom exceptions
class AppException extends Exception
{
public function __construct(
string $message,
public readonly string $code,
public readonly array $context = [],
?Throwable $previous = null
) {
parent::__construct($message, 0, $previous);
}
}
class ValidationException extends AppException
{
public function __construct(
public readonly array $errors,
?Throwable $previous = null
) {
parent::__construct(
'Validation failed',
'VALIDATION_ERROR',
['errors' => $errors],
$previous
);
}
}
{
{
::(
,
,
[ => , => ],
);
}
}
{
{}
{
(, , );
}
{
(, , );
}
{
(!->success) {
;
}
::((->value));
}
{
(!->success) {
;
}
(->value);
}
}
{
(([])) {
::();
}
{
= ([], [] ?? );
->repository->();
::();
} ( ) {
::(->());
}
}
<?php
// Array functions
$users = [
['name' => 'Alice', 'age' => 30],
['name' => 'Bob', 'age' => 25],
['name' => 'Charlie', 'age' => 35],
];
// Filter
$adults = array_filter($users, fn($u) => $u['age'] >= 30);
// Map
$names = array_map(fn($u) => $u['name'], $users);
// Reduce
$totalAge = array_reduce($users, fn($sum, $u) => $sum + $u['age'], 0);
// Find
$bob = array_filter($users, fn($u) => $u['name'] === 'Bob');
$bob = current($bob); // Get first match
// Sort
usort(, fn(, ) => [] <=> []);
{
(, function (, ) ($) {
$[$[$]][] = $;
;
}, []);
}
{
{}
{
();
}
{
((, ->items));
}
{
((->items, ));
}
{
(->items, , );
}
{
->items[(->items)] ?? ;
}
{
(->items);
}
{
(->items);
}
{
->items;
}
}
= ::()
->(fn() => [] >= )
->(fn() => [])
->();
<?php
// Interface definition
interface LoggerInterface
{
public function info(string $message, array $context = []): void;
public function error(string $message, array $context = []): void;
}
interface UserRepositoryInterface
{
public function find(string $id): ?User;
public function save(User $user): void;
}
// Service with constructor injection
class UserService
{
public function __construct(
private readonly UserRepositoryInterface $repository,
private readonly LoggerInterface $logger,
EventDispatcher
) {}
{
->logger->(, [ => ]);
= (, );
->repository->();
->events->( ());
;
}
}
{
= [];
= [];
{
->bindings[] = ;
}
{
->bindings[] = {
(!(->instances[])) {
->instances[] = ();
}
->instances[];
};
}
{
((->bindings[])) {
->bindings[]();
}
->();
}
{
= ();
= ->();
(!) {
();
}
= (
fn(ReflectionParameter ) => ->(->()->()),
->()
);
->();
}
}