Modern PHP programming skill - master PHP 8.x syntax, OOP, type system, and Composer
Provides comprehensive PHP 8.x training from syntax to advanced features. Use when users need to learn PHP fundamentals, OOP patterns, or modern features like property hooks and enums.
/plugin marketplace add pluginagentmarketplace/custom-plugin-php/plugin install php-assistant@pluginagentmarketplace-phpThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyAtomic skill for mastering modern PHP programming fundamentals
This skill provides comprehensive training in modern PHP development, from basic syntax to advanced PHP 8.4 features. Designed for progressive learning with hands-on exercises.
interface SkillParams {
topic:
| "syntax" // Variables, operators, control structures
| "oop" // Classes, interfaces, traits
| "type-system" // Type declarations, unions, intersections
| "php8-features" // Modern PHP 8.x features
| "composer" // Dependency management
| "standards"; // PSR compliance
level: "beginner" | "intermediate" | "advanced";
php_version?: "8.0" | "8.1" | "8.2" | "8.3" | "8.4";
output_format?: "tutorial" | "reference" | "exercises";
}
validation:
topic:
required: true
allowed: [syntax, oop, type-system, php8-features, composer, standards]
level:
required: true
allowed: [beginner, intermediate, advanced]
php_version:
default: "8.3"
topics:
- Variables and data types
- Operators and expressions
- Control structures (if, switch, match)
- Loops (for, foreach, while)
- Functions and closures
- Error handling basics
exercises:
- Build a calculator function
- Create array manipulation utilities
- Implement string processing functions
duration: 8-12 hours
prerequisites: none
topics:
- Classes and objects
- Properties and methods
- Inheritance and polymorphism
- Interfaces and abstract classes
- Traits and composition
- SOLID principles
exercises:
- Design a Shape hierarchy
- Implement Repository pattern
- Build a simple DI container
duration: 15-20 hours
prerequisites: [syntax]
topics:
php_8_0:
- Named arguments
- Constructor property promotion
- Match expressions
- Nullsafe operator
- Attributes
- Union types
php_8_1:
- Enums
- Readonly properties
- Fibers
- Intersection types
php_8_2:
- Readonly classes
- DNF types
php_8_3:
- Typed class constants
- json_validate()
- "#[Override]" attribute
php_8_4:
- Property hooks
- Asymmetric visibility
duration: 10-15 hours
graph TD
A[Skill Invoked] --> B{Valid Parameters?}
B -->|No| C[Return Validation Error]
B -->|Yes| D[Load Module Content]
D --> E{Level?}
E -->|Beginner| F[Basic Concepts + Examples]
E -->|Intermediate| G[Patterns + Exercises]
E -->|Advanced| H[Deep Dive + Best Practices]
F --> I[Generate Response]
G --> I
H --> I
errors:
INVALID_TOPIC:
code: "SKILL_001"
recovery: "Display available topics"
VERSION_MISMATCH:
code: "SKILL_002"
recovery: "Suggest minimum version or alternative"
retry:
max_attempts: 3
backoff:
type: exponential
initial_delay_ms: 100
max_delay_ms: 2000
multiplier: 2
hooks:
on_skill_start: [log_invocation, track_topic]
on_module_complete: [update_progress, award_badge]
on_error: [log_error, suggest_recovery]
on_skill_complete: [recommend_next_skill]
<?php
declare(strict_types=1);
// Variables and types
$name = 'PHP Developer';
$version = 8.3;
// Match expression (PHP 8.0+)
$status = match($code) {
200 => 'OK',
404 => 'Not Found',
default => 'Unknown',
};
<?php
declare(strict_types=1);
// Constructor property promotion (PHP 8.0+)
final readonly class User
{
public function __construct(
public int $id,
public string $email,
public string $name,
) {}
}
<?php
declare(strict_types=1);
// Property hooks (PHP 8.4+)
class Temperature
{
public float $celsius {
get => $this->celsius;
set => $value >= -273.15 ? $value : throw new \InvalidArgumentException();
}
public float $fahrenheit {
get => $this->celsius * 9/5 + 32;
set => $this->celsius = ($value - 32) * 5/9;
}
}
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\Test;
final class CalculatorTest extends TestCase
{
#[Test]
public function it_adds_two_numbers(): void
{
$calculator = new Calculator();
$this->assertSame(5, $calculator->add(2, 3));
}
}
| Problem | Cause | Solution |
|---|---|---|
| Type errors | Strict types + wrong type | Check function signature, cast values |
| Autoloading failures | PSR-4 mismatch | Verify namespace, run composer dump-autoload |
| Deprecated features | Old PHP patterns | Update to modern syntax |
| Metric | Target |
|---|---|
| Code example accuracy | 100% |
| PHP version correctness | 100% |
| PSR-12 compliance | 100% |
Skill("php-fundamentals", {topic: "oop", level: "intermediate"})
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.