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.
git clone --depth 1 https://github.com/ivangrynenko/cursorrulesWrote 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.
[](https://agentmods.dev/rules/ivangrynenko/cursorrules/php-memory-optimisation)<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/php-memory-optimisation"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/php-memory-optimisation/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.
<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/php-memory-optimisation"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/php-memory-optimisation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00878 |
| Opus 5.5 | $0.00000 | $0.00351 |
| Sonnet 5.5 | $0.00000 | $0.00176 |
| Haiku 4.5 | $0.00000 | $0.00088 |
Grade A, and why
php-memory-optimisation 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 1mo 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.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
- **Stream database results:** Prefer `$stmt->fetch(PDO::FETCH_ASSOC)` in a `while` loop or use generators instead of `fetchAll()`. What it actually says
PHP Memory Optimisation Standards
Guidance and automated checks to reduce peak memory usage in PHP applications. Based on widely accepted practices and the article "PHP Memory Optimization Tips" by Khouloud Haddad.
actions:
-
type: enforce conditions:
Avoid loading entire DB result sets into memory.
-
pattern: "->fetchAll\(" message: "Avoid fetchAll() on large result sets; iterate with fetch() in a loop or wrap with a generator (yield)."
-
pattern: "\bmysqli_fetch_all\(" message: "Avoid mysqli_fetch_all() for large queries; prefer streaming fetch (e.g., mysqli_fetch_assoc in a loop)."
Avoid repeated full-file loads inside loops.
- pattern: "foreach\s*\([^)]\)\s\{[^}]*file_get_contents\(" message: "Avoid file_get_contents() inside loops; stream with SplFileObject or read once and reuse."
Avoid array_merge in tight loops as it copies arrays.
- pattern: "foreach\s*\([^)]\)\s\{[^}]=\sarray_merge\(" message: "Avoid array_merge() inside loops; append elements directly or preallocate arrays."
Use caution with range() on large ranges (allocates full array).
- pattern: "\brange\s*\(" message: "range() allocates full arrays; for large ranges consider generators (yield) to avoid high memory."
-
-
type: suggest message: | PHP memory optimisation recommendations:
- Stream database results: Prefer
$stmt->fetch(PDO::FETCH_ASSOC)in awhileloop or use generators instead offetchAll(). - Use generators (yield): Iterate large datasets without allocating full arrays.
- Stream files: Use
SplFileObjector chunked reads instead offile_get_contents()for large files. - Minimise array copying: Avoid
array_merge()in loops; push items directly or pre-size with known capacity (e.g.,SplFixedArray). - Free memory explicitly:
unset($var)after large data is no longer needed; considergc_collect_cycles()for long-running scripts. - Profile memory: Use
memory_get_usage()and tools like Xdebug/Blackfire to spot peaks. - OPcache: Ensure OPcache is enabled and sized appropriately in production.
- Stream database results: Prefer
-
type: validate conditions:
Detect full-file reads that likely could be streamed.
- pattern: "\bfile\s*\(" message: "file() reads entire files into memory; prefer SplFileObject for line-by-line streaming."
metadata: priority: high version: 1.0
actions:
-
type: suggest message: | OPcache recommendations (php.ini):
- Set
opcache.enable=1andopcache.enable_cli=1for CLI scripts that process large datasets. - Size memory pool appropriately, e.g.,
opcache.memory_consumption=128(adjust to your project). - Consider
opcache.interned_strings_bufferandopcache.max_accelerated_filesfor larger codebases.
- Set
-
type: enforce conditions:
- pattern: "(?mi)^opcache\.enable\s*=\s*0" message: "Enable OPcache in production (set opcache.enable=1) to reduce memory and CPU overhead."
metadata: priority: medium version: 1.0
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.
- 1mo ago First seen · 86 lines · 878 tokens per session scan A df596c1fd54a
php-memory-optimisation is a cursor rule published in the GitHub repository ivangrynenko/cursorrules (88 stars, last pushed 11mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 878 tokens. 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-09-03.
Other cursor rules, from other repositories
laravel
Laravel: Eloquent, Form Requests, policies.
laravel-php-83-cursorrules-prompt-file
Cursor rules for Laravel development with PHP 8.3 integration.
laravel-package-development-guidelines
A set of coding rules for building Laravel packages, which are reusable extensions for Laravel applications. It covers package structure, code style, helper functions, type safety, editor suggestions, and documentation.
laravel-package-coding-standards
A set of coding rules for Laravel packages, with conventions for names and code across several development areas.
laravel-package-structure
A set of coding rules for organising a Laravel package, a reusable extension for Laravel applications.
laravel
Core Laravel architecture and coding conventions.