PHPackages                             jensderond/phpstan-craftcms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jensderond/phpstan-craftcms

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jensderond/phpstan-craftcms
===========================

CraftCMS extension for PHPStan

1.3.0(3w ago)03.1k—4.3%MITPHP

Since Oct 30Pushed 3w agoCompare

[ Source](https://github.com/Jensderond/phpstan-craftcms)[ Packagist](https://packagist.org/packages/jensderond/phpstan-craftcms)[ RSS](/packages/jensderond-phpstan-craftcms/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (9)Versions (12)Used By (0)

phpstan-craftcms
================

[](#phpstan-craftcms)

[![Packagist Version](https://camo.githubusercontent.com/2da6a83a2c862c24b69372489309dcb417e74c57add61c6259b487afae211921/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a656e736465726f6e642f7068707374616e2d6372616674636d73)](https://camo.githubusercontent.com/2da6a83a2c862c24b69372489309dcb417e74c57add61c6259b487afae211921/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a656e736465726f6e642f7068707374616e2d6372616674636d73)

Extension for PHPStan for better support for Craft CMS. The following features are provided:

- Configure autoload of Craft CMS for analysis
- Stubs for `Entry` and `ElementQuery`, narrowing `EntryQuery::one()`, `nth()` and `all()` to return `Entry`
- Dependency injection container support for `Craft::$container->get()`
- Recognises custom field handles as properties on `Element` and `ElementQuery`, including handle overrides from entry-type field layouts (read from your project config)
- Validates the `action` value of Twig `actionInput()` calls against discovered controller routes (including shorthand routes for controller default actions)

Install
-------

[](#install)

Via Composer

```
$ composer require --dev jensderond/phpstan-craftcms
```

Usage
-----

[](#usage)

Add `phpstan-craftcms` to the project `phpstan.neon` / `phpstan.neon.dist`:

```
includes:
    - vendor/jensderond/phpstan-craftcms/extension.neon
```

Configuration
-------------

[](#configuration)

The extension exposes the following parameters with sensible defaults:

```
parameters:
    yii2:
        config_path: %rootDir%/../../../config/app.php
    craftcms:
        projectConfigPath: %currentWorkingDirectory%/config/project
    craftActionInput:
        templatePaths:
            - %currentWorkingDirectory%/templates
            - %currentWorkingDirectory%/modules
            - %currentWorkingDirectory%/plugins
        handleMap: []
```

- `yii2.config_path` — path to your Yii/Craft application config used to build the service and route maps.
- `craftcms.projectConfigPath` — path to the Craft project config directory; used to collect custom field handles and entry-type handle overrides.
- `craftActionInput.templatePaths` — directories scanned for Twig `actionInput()` calls.
- `craftActionInput.handleMap` — optional map of additional handle aliases used when resolving `actionInput()` values to controllers.

Credits
-------

[](#credits)

- [studio-stomp/phpstan-craftcms](https://github.com/studio-stomp/phpstan-craftcms)
- [marcusgaius/phpstan](https://github.com/marcusgaius/phpstan)
- [erickskrauch/phpstan-yii2](https://github.com/erickskrauch/phpstan-yii2)

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance96

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~30 days

Total

7

Last Release

21d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ab5fe6ad2222d8ebbfedf7ace24b0e0c8647c9e321df07772ea39536fa69cd1?d=identicon)[jensderond](/maintainers/jensderond)

---

Top Contributors

[![Jensderond](https://avatars.githubusercontent.com/u/6972822?v=4)](https://github.com/Jensderond "Jensderond (17 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jensderond-phpstan-craftcms/health.svg)

```
[![Health](https://phpackages.com/badges/jensderond-phpstan-craftcms/health.svg)](https://phpackages.com/packages/jensderond-phpstan-craftcms)
```

###  Alternatives

[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k8.8M118](/packages/deptrac-deptrac)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87718.9k56](/packages/ticketswap-phpstan-error-formatter)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)[ergebnis/rector-rules

Provides rules for rector/rector.

10245.6k51](/packages/ergebnis-rector-rules)[shopsys/coding-standards

Coding standards definition compatible with PSR-2

20280.7k20](/packages/shopsys-coding-standards)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
