Agent skill
PHP Error Handling
Modern PHP error and exception handling standards.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/error-handling-fierzone-agent-skills-standar
Metadata
Additional technical details for this skill
- labels
-
php exceptions error-handling psr-3
- triggers
-
{ "files": [ "**/*.php" ], "keywords": [ "try", "catch", "finally", "Throwable", "set_exception_handler" ] }
SKILL.md
PHP Error Handling
Priority: P0 (CRITICAL)
Structure
src/
└── Exceptions/
├── {Domain}Exception.php
└── Handler.php
Implementation Guidelines
- Exception-Driven: Prefer throwing exceptions over returning
false. - Throwable Interface: Catch
Throwablefor both Errors and Exceptions. - Custom Exceptions: Extend
RuntimeExceptionfor domain-specific errors. - Multi-catch: Use
catch (TypeA | TypeB $e)for identical handling. - Finally Cleanup: Use
finallyto ensure resource release. - Global Handling: Set
set_exception_handlerin entry points. - PSR-3 Logging: Log critical faults using standard loggers.
Anti-Patterns
- Error Suppression: No @: Avoid suppressing errors with
@. - Silent Catch: No Empty Catches: Log or handle all caught exceptions.
- Logic Flow: No Flow Control: Don't use exceptions for expected logic.
- Panic Display: No display_errors: Log to file, never to production screen.
References
- Exception & Logging Patterns
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?