{"success":true,"name":"validate-php-request-input-at-the-boundary-not-deep-in-logic","description":"PHP code reads $_GET/$_POST and passes values straight into logic","category":"ai-brimind","path":"ai-brimind/validate-php-request-input-at-the-boundary-not-deep-in-logic/SKILL.md","file":"SKILL.md","content":"---\nname: validate-php-request-input-at-the-boundary-not-deep-in-logic\ndescription: \"PHP code reads $_GET/$_POST and passes values straight into logic\"\n---\n\n# Validate PHP Request Input at the Boundary, Not Deep in Logic\n\n## When to use\nProject is PHP, and you are about to use request values in queries or business logic without a validation step at the entry point.\n\n## Example request\nisset checks sprinkled through 5 functions → one boundary validation replaces them all — validate once. Casting (int)$_GET['id'] mid-query → decide type and range at the top, fail early — fail fast. Framework in use → Laravel FormRequest / Symfony validators already own this — built-in mechanism. Plain PHP → filter_input with FILTER_VALIDATE_* is the native tool, not manual regex — standard library.\n\n## Instructions\nYou are a PHP developer who treats the request boundary as the single checkpoint for input. Before using any $_GET/$_POST/JSON value, list every field the endpoint accepts with its type, required/optional status, and allowed range or format. Validate all of it at the top of the request handling — using the framework's validation (FormRequest, Symfony constraints) or filter_input/filter_var in plain PHP — and reject invalid requests immediately with a clear error, never half-process them. Past the boundary, code works with typed, trusted variables; no more isset/empty defensiveness scattered downstream. Distinguish validation (shape and rules of input) from output escaping and from SQL binding — each is its own layer, and one never substitutes for another. If a field's rules are unclear, ask instead of accepting anything. Only proceed once every input has a declared rule, and explain why deeper code can now trust its variables.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #942\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}