Skip to content
thebushidocollective avatar

PHP Security Patterns

Reference guide of PHP security patterns covering validation, SQL injection, XSS, CSRF, and password handling.

CCM score
48 of 100
skills.sh installs
279
GitHub stars
202
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers input validation, SQL injection prevention, XSS protection, CSRF defense, password hashing, session security, and file upload safety
  • Includes PHP code examples for email, URL, and integer validation, output encoding with htmlspecialchars, and PDO prepared statements
  • Enforces validation at the application boundary and output encoding before rendering to prevent injection attacks
  • Designed for developers building PHP applications that handle authentication, personal data, or financial transactions

Install

$ npx -y skills add thebushidocollective/han --skill 'PHP Security Patterns' -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

PHP Security Patterns

Introduction

Security is paramount in PHP applications as they often handle sensitive user data, authentication, and financial transactions. PHP's flexibility and dynamic nature create opportunities for vulnerabilities if security best practices aren't followed.

Common PHP security vulnerabilities include SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), insecure password storage, session hijacking, and file inclusion attacks. Each can lead to data breaches, unauthorized access, or complete system compromise.

This skill covers input validation and sanitization, SQL injection prevention, XSS protection, CSRF defense, secure password handling, session security, file upload security, and defense-in-depth strategies.

Input Validation and Sanitization

Input validation ensures data meets expected formats before processing, while sanitization removes or encodes potentially dangerous content.

<?php
declare(strict_types=1);

// Email validation
function validateEmail(string $email): bool {
    return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}

Details

Repository
github.com/thebushidocollective/han
Categories
Security, PHP & Laravel
First seen
Jun 3, 2026

Questions

What does the PHP Security Patterns skill cover?

PHP Security Patterns covers input validation and sanitization, SQL injection prevention with prepared statements, XSS protection, CSRF defense, password hashing, secure session management, file upload security, and defense-in-depth strategies. It is aimed at building secure PHP applications that handle user data, authentication and transactions.

How do I install the PHP Security Patterns skill?

Run this command in a project: npx -y skills add thebushidocollective/han --skill 'PHP Security Patterns' -y. Once installed, PHP Security Patterns gives the agent guidance on writing PHP code that resists common attacks.

Which Security category skills does PHP Security Patterns sit alongside?

PHP Security Patterns is listed in the Security category on Claude Marketplaces, next to azure-compliance, entra-agent-id, firebase-security-rules-auditor, security-audit and cloudflare-one. Unlike those skills, it focuses specifically on PHP coding patterns such as PDO prepared statements and output encoding.

Does PHP Security Patterns need any tools, accounts or API keys?

The skill declares no allowed tools, and its SKILL.md is pure guidance with PHP code examples. It needs a PHP runtime with PDO to run the examples, and no account or API key is mentioned in its listing.

More from thebushidocollective/han

All 14

Similar to PHP Security Patterns

More Security