getting-started
Skill4 starsChanged 4 months agoMITView on GitHub
Add static analysis to a PHP project with PHPStan — install it, write a phpstan.neon config, pick an analysis level (0–10), run the analyser, wire up paths and includes, and read the common first errors it reports. Use when the user wants to choose or raise a PHPStan analysis level (0 through 10) for their code; the user wants to write or edit a `phpstan.neon` config to set paths, level, includes, or ignore rules; the user wants to install PHPStan and run static analysis on a PHP codebase for the first time. Keywords: phpstan, static-analysis, phpstan-neon, levels, analysis.
32 other projects use a version of this.
Adopted by
Most recently taken up by
- seayniclabs/homelab-infra-mcptheir own version, first seen Nov 8, 2026
- celigo/aitheir own version, first seen Nov 5, 2026
- orgiggly/claude-plugintheir own version, first seen Nov 2, 2026
- claude-world/director-mode-litetheir own version, first seen Nov 1, 2026
- seayniclabs/lathetheir own version, first seen Nov 1, 2026
- jackstine/forgectltheir own version, first seen Nov 1, 2026
Other versions32 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 32
- NVIDIA-NeMo/Curator★ 1.9ksame name
- davekilleen/Dex★ 509same name
- aivrar/portable-hermes-agent★ 239same name
- GoogleCloudPlatform/race-condition★ 232same name
- taskade/mcp★ 170same name
- claude-world/director-mode-lite★ 80same name
- dylantarre/design-system-skills★ 50same name
- crewAIInc/skills★ 45same name
- aks129/HealthClawGuardrails★ 33same name
- ayrshare/ayrshare-social-media-api-claude-plugin★ 19same name
22 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 32 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 65
Do not use PHPStan to enforce code style, spacing, or formatting.
- Distinctive: line 67
Do not reach for PHPStan to verify runtime behavior or business logic.
- Very specific: line 84
Create phpstan.neon at the project root with parameters.level: 0 and parameters.paths: [src] (add tests if you analyse them).
- Very specific: line 86
Run vendor/bin/phpstan analyse.
- Very specific: line 93
When you must silence an error, add a specific ignoreErrors entry scoped by message regex and path, rather than lowering the level or …
- Distinctive: line 128
Not applicable — no I/O, auth, or untrusted input.
“Common” is measured: kept by at least 6 in 10 of the 32 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/phpstan/getting-started/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->PHPStan Getting Started
When to use
- The user wants to choose or raise a PHPStan analysis level (0 through 10) for their code.
- The user wants to write or edit a
phpstan.neonconfig to set paths, level, includes, or ignore rules. - The user wants to install PHPStan and run static analysis on a PHP codebase for the first time.
When NOT to use
- Do not use PHPStan to enforce code style, spacing, or formatting; use a fixer such as PHP-CS-Fixer or PHP_CodeSniffer instead.
- Do not reach for PHPStan to verify runtime behavior or business logic; write unit or feature tests for that.
Core guidance
- Analyse your own source, not vendor — Point
pathsat your own directories (e.g.src,app,tests) and never addvendortopaths; PHPStan reads third-party code for context automatically. - Keep level and paths in phpstan.neon, not CLI flags — Declare
levelandpathsin a committedphpstan.neon(orphpstan.dist.neon) rather than passing--leveland directories on the command line. - Run analysis in CI and fail on a non-zero exit — Run
vendor/bin/phpstan analysein CI and treat its non-zero exit code as a build failure so new type errors cannot merge. - Start at a low level and raise it gradually — Start analysis at level 0 (or
level: maxonly on greenfield code), get a green run, then raise thelevelone step at a time and fix the new errors each step.
Quick recipe
- Install the analyser with
composer require --dev phpstan/phpstan. (verify:vendor/bin/phpstan --versionprints a version number.) - Create
phpstan.neonat the project root withparameters.level: 0andparameters.paths: [src](addtestsif you analyse them). (verify: The file parses and lists your own source directories under paths.) - Run
vendor/bin/phpstan analyse; once it is green, bumplevelby one, fix the new errors, and repeat until you reach your target level. (verify: The analyser exits 0 at the current level before you raise it.)
Best practices
- Pull in framework and library type extensions through the
includeskey inphpstan.neon(e.g - When you must silence an error, add a specific
ignoreErrorsentry scoped by message regex andpath, rather than lowering the level or ignoring broadly
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Adding vendor to the analysed paths | Third-party code produces errors you cannot fix, drowns your own findings, and<br>makes each run far slower for no benefit. | List only your own source directories in paths; PHPStan still reads vendor code<br>for type information without analysing it. |
| Silencing errors with a blanket ignore | A blanket ignore or a lowered level hides every future real bug in that scope, not<br>just the one you meant to accept. | Write a specific message regex scoped to a path, or adopt a baseline so existing<br>errors are frozen while new code stays fully analysed. |
| Setting level max on day one of a legacy project | A cold max-level run on legacy code surfaces thousands of errors at once, which<br>nobody triages, so the tool gets muted or removed entirely. | Start at level 0, commit a green baseline, and raise the level one step at a time,<br>fixing each step's errors before advancing. |
See references/anti-patterns.md.
Common mistakes
- Reflection or class-not-found errors from missing autoload — PHPStan reports "class not found" or reflection errors when it cannot autoload
classes that are not covered by Composer's autoloader. Fix: Add the extra paths under
scanFiles/scanDirectoriesinphpstan.neon, or make the classes loadable viacomposer dump-autoload, so PHPStan can resolve them. - Analysis dies with a memory-limit fatal — On large codebases the analyser can exhaust PHP's
memory_limitand abort with a fatal before finishing. Fix: Raise the limit for the run withphpstan analyse --memory-limit=1G, or set a highermemory_limitin the CLI php.ini used by CI. - Stale result cache hides or invents errors — After changing config, PHP version, or extensions, a stale result cache can report
errors that are already fixed or miss new ones. Fix: Run
phpstan clear-result-cache(or delete thetmpDir) after changing the neon config, PHP version, or included extensions, then re-analyse.
Version notes
- Level 10 and level max in PHPStan 2.x (PHP >=7.4) — PHPStan 2.0 added analysis level 10, and
level: maxis an alias that always points at the current highest level (10 today); on PHPStan 1.x the top level was 9. - phpstan.neon.dist and local override precedence (PHP >=7.4) — PHPStan auto-discovers
phpstan.neonthen falls back tophpstan.neon.dist; commit the shared config asphpstan.neon.distand let developers add a gitignoredphpstan.neonfor local-only overrides.
Security
- Not applicable — no I/O, auth, or untrusted input.
Testing
- Activation and decision behavior are verified in
eval/scenarios/phpstan/getting-started.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Prerequisites: php/typed-properties
Related: testing/pest-basics
<!-- graph-fragment: graph/fragments/phpstan/getting-started.yaml -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

