code-testing-requirements

A set of project rules for testing every PHP code example used in tutorials. It defines where examples go, how to run the tests, and which PHP and coding standards they must follow.

In plain words
What is it for?
Use it when adding or reviewing tutorial code, especially PHP 8.4 examples. It guides copying examples into the testing folders, running the test script, and updating the summary report.
Why use it?
It helps catch broken or incomplete examples before readers see them. It also makes test results and expected failures easier to track.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/dalehurley/codewithphp/code-testing-requirements
Clone the repo
git clone --depth 1 https://github.com/dalehurley/codewithphp

Made for: Cursor.

Per session 1,206 This file is loaded in full into every session.
When invoked 1,206 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01206 $0.01206
Opus 5 $0.00603 $0.00603
Sonnet 5 $0.00241 $0.00241
Haiku 4.5 $0.00121 $0.00121

Measured yesterday against content hash f0b86e557907, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-testing-requirements scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

# Test in browser or with curl
.cursor/rules/code-testing-requirements.mdc · 167 lines

How it starts

The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Code Testing Requirements

Testing Directory Structure

All code snippets and samples from tutorials MUST be tested in the /testing directory before being considered complete.

Testing Requirements

For New Code Samples

When creating new code samples for tutorials:

  1. Copy to Testing Directory

    • Place files in appropriate /testing/{series-name}/ subdirectory
    • Maintain same directory structure as docs/series/
  2. Run Test Script

    cd /Users/dalehurley/Code/PHP-From-Scratch/testing
    php test-all-samples.php
    
  3. Verify Results

    • ✅ Code must execute without errors (return code 0)
    • OR document expected failures (web server context, dependencies, etc.)
    • Update TEST-SUMMARY-REPORT.md if needed

Code Quality Standards

All tutorial code samples must:

  • ✅ Be complete and runnable (no partial code)
  • ✅ Use PHP 8.4 syntax and features
  • ✅ Include proper error handling where appropriate
  • ✅ Follow PSR-12 coding standards
  • ✅ Have no type errors or undefined variables (unless intentional for teaching)
  • ✅ Include comments explaining key concepts
  • ✅ Cast types explicitly when needed ((string), (int), etc.)

Expected Failure Categories

Some failures are acceptable if documented:

  1. Web Server Context - Files requiring $_SERVER variables, headers, or HTTP requests
  2. Missing Dependencies - Files requiring Composer packages or external libraries
  3. Configuration Required - Files needing database connections, API keys, or setup
  4. Educational Errors - Intentional errors demonstrating common mistakes
  5. Integration Files - Files designed as part of larger applications (routers, controllers)

Read the full file on GitHub · 167 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 167 lines · 1,206 tokens per session scan A f0b86e557907

Subscribe to this mod's changes

code-testing-requirements is a cursor rule published in the GitHub repository dalehurley/codewithphp (5 stars, last pushed 6mo ago), licensed MIT. It adds 1,206 tokens to every session, about $0.0060 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.