

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# PHP Memory Optimisation Standards67Guidance 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.89<rule>10name: php_memory_optimisation11description: Detect memory-heavy patterns and suggest streaming, generators, and better data handling12filters:13 - type: file_extension14 pattern: "\\.php$"1516actions:17 - type: enforce18 conditions:19 # Avoid loading entire DB result sets into memory.20 - pattern: "->fetchAll\\("21 message: "Avoid fetchAll() on large result sets; iterate with fetch() in a loop or wrap with a generator (yield)."2223 - pattern: "\\bmysqli_fetch_all\\("24 message: "Avoid mysqli_fetch_all() for large queries; prefer streaming fetch (e.g., mysqli_fetch_assoc in a loop)."2526 # Avoid repeated full-file loads inside loops.27 - pattern: "foreach\\s*\\([^)]*\\)\\s*\\{[^}]*file_get_contents\\("28 message: "Avoid file_get_contents() inside loops; stream with SplFileObject or read once and reuse."2930 # Avoid array_merge in tight loops as it copies arrays.31 - pattern: "foreach\\s*\\([^)]*\\)\\s*\\{[^}]*=\\s*array_merge\\("32 message: "Avoid array_merge() inside loops; append elements directly or preallocate arrays."3334 # Use caution with range() on large ranges (allocates full array).35 - pattern: "\\brange\\s*\\("36 message: "range() allocates full arrays; for large ranges consider generators (yield) to avoid high memory."3738 - type: suggest39 message: |40 **PHP memory optimisation recommendations:**4142 - **Stream database results:** Prefer `$stmt->fetch(PDO::FETCH_ASSOC)` in a `while` loop or use generators instead of `fetchAll()`.43 - **Use generators (yield):** Iterate large datasets without allocating full arrays.44 - **Stream files:** Use `SplFileObject` or chunked reads instead of `file_get_contents()` for large files.45 - **Minimise array copying:** Avoid `array_merge()` in loops; push items directly or pre-size with known capacity (e.g., `SplFixedArray`).46 - **Free memory explicitly:** `unset($var)` after large data is no longer needed; consider `gc_collect_cycles()` for long-running scripts.47 - **Profile memory:** Use `memory_get_usage()` and tools like Xdebug/Blackfire to spot peaks.48 - **OPcache:** Ensure OPcache is enabled and sized appropriately in production.4950 - type: validate51 conditions:52 # Detect full-file reads that likely could be streamed.53 - pattern: "\\bfile\\s*\\("54 message: "file() reads entire files into memory; prefer SplFileObject for line-by-line streaming."5556metadata:57 priority: high58 version: 1.059</rule>6061<rule>62name: php_ini_opcache_recommendations63description: Recommend enabling OPcache for lower memory and better performance when editing php.ini64filters:65 - type: file_extension66 pattern: "\\.ini$"6768actions:69 - type: suggest70 message: |71 **OPcache recommendations (php.ini):**72 - Set `opcache.enable=1` and `opcache.enable_cli=1` for CLI scripts that process large datasets.73 - Size memory pool appropriately, e.g., `opcache.memory_consumption=128` (adjust to your project).74 - Consider `opcache.interned_strings_buffer` and `opcache.max_accelerated_files` for larger codebases.7576 - type: enforce77 conditions:78 - pattern: "(?mi)^opcache\\.enable\\s*=\\s*0"79 message: "Enable OPcache in production (set opcache.enable=1) to reduce memory and CPU overhead."8081metadata:82 priority: medium83 version: 1.084</rule>8586
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ivangrynenko/cursorrules.cursor/rules/cursor-rules.mdc · 86 | Cursor rules | teststylearchgit+2 | 77/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-steps.mdc · 86 | Cursor rules | lint-formatstyleperformanceagent-behaviour | 42/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/php-drupal-development-standards.mdc · 86 | Cursor rules | no sections | 34/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-insecure-design.mdc · 86 | Cursor rules | no sections | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-cryptographic-failures.mdc · 86 | Cursor rules | security | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-injection.mdc · 86 | Cursor rules | styledo-not | 51/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/node-dependencies.mdc · 86 | Cursor rules | no sections | 16/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-ai-guide.mdc · 86 | Cursor rules | testtesting-strategydo-not | 45/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/new-pull-request.mdc · 86 | Cursor rules | archtesting-strategygitsecurity+3 | 58/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/accessibility-standards.mdc · 86 | Cursor rules | ui | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/api-standards.mdc · 86 | Cursor rules | api | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/build-optimization.mdc · 86 | Cursor rules | build | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/code-generation-standards.mdc · 86 | Cursor rules | lint-formatstyletypesdocs | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/confluence-editing-standards.mdc · 86 | Cursor rules | stylearchsecuritydeployment | 60/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/debugging-standards.mdc · 86 | Cursor rules | no sections | 30/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/docker-compose-standards.mdc · 86 | Cursor rules | style | 62/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-authentication-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-broken-access-control.mdc · 86 | Cursor rules | stylesecurity | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-cryptographic-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-database-standards.mdc · 86 | Cursor rules | database | 30/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/ivangrynenko-cursorrules-cursor-rules-php-memory-optimisation)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.
Directory