php-basics-patterns

php-basics-patterns is a cursor rule for Cursor from dalehurley/codewithphp. It costs 11 tokens per session (2,906 once invoked), scanned A, original, MIT.

A set of writing patterns for a PHP basics course, covering a staged path from core language features to object-oriented programming, tools, applications, and frameworks. Object-oriented programming organizes code around reusable objects and their behavior.

In plain words
What is it for?
Use it to structure chapters with goals, numbered actions, code examples, expected results, and explanations of why the code works.
Why use it?
It helps new lessons follow a consistent learning order, so frameworks are introduced only after the underlying PHP concepts are understood.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it to structure chapters with goals, numbered actions, code examples, expected results, and explanations of why the code works.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/dalehurley/codewithphp/php-basics-patterns
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.

Clone the repo
git clone --depth 1 https://github.com/dalehurley/codewithphp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for php-basics-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/dalehurley/codewithphp/php-basics-patterns/github.svg)](https://agentmods.dev/rules/dalehurley/codewithphp/php-basics-patterns)
Your own site
<a href="https://agentmods.dev/rules/dalehurley/codewithphp/php-basics-patterns"><img src="https://agentmods.dev/badge/rules/dalehurley/codewithphp/php-basics-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for php-basics-patterns

Your own site · 80×15
<a href="https://agentmods.dev/rules/dalehurley/codewithphp/php-basics-patterns"><img src="https://agentmods.dev/badge/rules/dalehurley/codewithphp/php-basics-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,906 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00011 $0.02906
Opus 5.5 $0.00004 $0.01162
Sonnet 5.5 $0.00002 $0.00581
Haiku 4.5 $0.00001 $0.00291

Measured 9d ago against content hash eb7187fcff84, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

php-basics-patterns scanned grade A with 0 findings 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 9d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/php-basics-patterns.mdc · 563 lines

How it starts

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

PHP Basics Series: Patterns & Conventions

This document captures specific patterns, conventions, and best practices observed in the php-basics series that should be replicated in new series.

Chapter Progression Philosophy

The php-basics series follows a deliberate learning path:

  1. Foundation First (Ch 00-07): Core language features with no OOP
  2. Paradigm Shift (Ch 08-10): Introduction to OOP concepts
  3. Professional Tools (Ch 11-16): Real-world development practices
  4. Application Building (Ch 17-19): Integrating all concepts into projects
  5. Framework Introduction (Ch 20-22): Transition to frameworks with strong foundation

Key Principle: Don't introduce frameworks until fundamentals are mastered. Build understanding from scratch.

Step Structure Pattern

Every step follows this exact format:

## Step N: Descriptive Action Title (~X min)

### Goal

Single sentence stating the purpose of this step.

### Actions

1. **Do this first**: Explanation
2. **Then do this**: Explanation
3. **Code to write**:

```language
# filename: file.ext
code here
```

Expected Result

Exact output or state

Why It Works

Explanation of underlying concepts (2-4 sentences)

Troubleshooting

  • Error message or symptom — Cause and solution
  • Another common issue — Fix

**Rules:**
- Goal is always a single sentence
- Actions are numbered and use bold for the action verb
- Code examples always include filename comment
- Expected Result shows exact output
- Why It Works explains concepts, not just mechanics
- Troubleshooting includes at least 2-3 common issues

## Code Example Patterns

### PHP Script Pattern

```php
# filename: descriptive-name.php
<?php

declare(strict_types=1);

// Brief comment explaining the example
class Example
{
    // Implementation
}

// Usage demonstration
$example = new Example();
echo $example->doSomething();

Key Elements:

  • Filename comment at top
  • declare(strict_types=1); for modern examples
  • Opening <?php tag always present
  • No closing ?> tag for pure PHP files
  • Brief explanatory comments
  • Show both definition and usage
  • Include output demonstration

Command Pattern

Read the full file on GitHub · 563 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. 9d ago Changed eb7187fcff84
  2. 3mo ago First seen · 563 lines · 11 tokens per session scan A 783dd0551c27

Subscribe to this mod's changes

php-basics-patterns is a cursor rule published in the GitHub repository dalehurley/codewithphp (6 stars, last pushed 7d ago), licensed MIT. It adds 11 tokens to every session and 2,906 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

php-basics-patterns compared with cursor rules from other repositories

php-basics-patterns next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
php-basics-patternsdalehurley/codewithphpCursor rule67d agoMITA11Cursor
moodle-upgrade-migrationSaadRahman01/claude-moodle-devCursor rule435mo agoMITA0Cursor
laravelsanjeed5/awesome-cursor-rules-mdcCursor rule3.6k7d agoCC0-1.0A2,628Cursor
laravel-package-coding-standardsholtwood/awesome-cursorrules-zhCursor rule2441mo agoMITA0Cursor
bundlingbubblelabai/BubbleLabCursor rule1.1k7mo agoApache-2.0A1,505Cursor
backendshopsys/shopsysCursor rule349todaynoneA0Cursor
react-vite-tanstackunoplat/unoplat-code-confluenceCursor rule9325d agononeA631Cursor