PHPackages                             efabrica/phpstan-latte - 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. efabrica/phpstan-latte

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

efabrica/phpstan-latte
======================

0.20.0(2mo ago)4512.2k↑28.1%8[21 issues](https://github.com/efabrica-team/phpstan-latte/issues)[5 PRs](https://github.com/efabrica-team/phpstan-latte/pulls)MITPHPPHP &gt;=7.4 &lt;8.6CI passing

Since Nov 18Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/efabrica-team/phpstan-latte)[ Packagist](https://packagist.org/packages/efabrica/phpstan-latte)[ RSS](/packages/efabrica-phpstan-latte/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (26)Versions (34)Used By (0)

PHPStan Latte extension
=======================

[](#phpstan-latte-extension)

PHPStan extension to check compiled Latte templates in context of a Presenter or a Component etc. Templates are compiled to PHP code which is then analyzed with PHPStan rules according to a configured [rule level](https://phpstan.org/user-guide/rule-levels) and rules from loaded extensions.

The extension is based on Tomas Votruba's [blog series](https://tomasvotruba.com/blog/stamp-static-analysis-of-templates/) and his packages symplify and reveal.

[![Preview](docs/preview.png)](docs/preview.png)

Features
--------

[](#features)

- Supports Latte 2 and Latte 3
- Templates are analysed in context in which they are rendered (one template can be analysed with different contexts if it is used on multiple places)
- Automatically collects all existing template variables, components, simple forms, render calls,... from PHP code.
- Analyses existence and parameters of filters and functions.
- Can analyse existence and parameters of links (if you configure `applicationMapping`).
- Can use pre-configured latte engine from your application container (no need to configure manually)
- Analyses existence of components, forms and form fields used in template
- Analyses included templates in context of including template
- Can resolve rendered template path even from more complex expressions (but still has limitations)
- Can report unanalysed templates
- You can use annotations to fine-tuning analysis of latte templates
- If you use some non-standard and magic using rendering you can implement your own template resolvers (experimental)

Read [How it works, when it doesn't, and troubleshooting](docs/how_it_works.md)

Installation
------------

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require efabrica/phpstan-latte --dev
```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationAdd this line to your phpstan.neon:

```
includes:
    - vendor/efabrica/phpstan-latte/rules.neon
```

It is recommended to use this extension with [phpstan-nette](https://github.com/phpstan/phpstan-nette) extension for better analysis of templates.

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

[](#configuration)

- [Latte engine configuration](docs/configuration.md#latte-engine-configuration)
- [Analyser configuration](docs/configuration.md#analyser-configuration)
- [Ignoring errors](docs/configuration.md#ignoring-errors)
- [Link checking](docs/configuration.md#link-checking)
- [Other configuration options](docs/configuration.md#other-configuration-options)

If analysis reports errors about missing context (variables/components, ...) set in external packages you need to set option `latte.collectedPaths` as descibed in [Analyser configuration](docs/configuration.md#analyser-configuration).

Annotations
-----------

[](#annotations)

There are cases that cannot be resolved automatically by static analysis.

In these cases annotations line `@phpstan-latte-ignore` or `@phpstan-latte-var` could be used to guide resolvers to analyse latte templates correctly.

[How to use annotations](docs/annotations.md)

How to extend this extension
----------------------------

[](#how-to-extend-this-extension)

This extension supports only common built-in methods for resolving paths to latte files, collecting variables, components, forms etc. However, we know that in a wild there are applications which use their own methods for these purposes. That's why we create this extension extensible. See more about this topic [here](docs/extension.md).

Development
-----------

[](#development)

[Changelog](CHANGELOG.md)

If you want to contribute your PR are welcomed. If you want to discuss your idea first then create issue.

---

Thank you for using this package. Let us know if it helped you or what could be improved.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance74

Regular maintenance activity

Popularity38

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 56.5% 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 ~47 days

Recently: every ~157 days

Total

27

Last Release

88d ago

PHP version history (5 changes)0.1.0PHP &gt;=7.4 &lt;=8.2

0.3.0PHP &gt;=7.4 &lt;8.3

0.16.3PHP &gt;=7.4 &lt;8.4

0.19.0PHP &gt;=7.4 &lt;8.5

0.20.0PHP &gt;=7.4 &lt;8.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/25289c62a88df1c404543693ba52e44748dbce486bcfab91fc8c5931a6bb38e1?d=identicon)[dev-efabrica](/maintainers/dev-efabrica)

---

Top Contributors

[![MartinMystikJonas](https://avatars.githubusercontent.com/u/2094752?v=4)](https://github.com/MartinMystikJonas "MartinMystikJonas (298 commits)")[![lulco](https://avatars.githubusercontent.com/u/9377319?v=4)](https://github.com/lulco "lulco (214 commits)")[![spaze](https://avatars.githubusercontent.com/u/1966648?v=4)](https://github.com/spaze "spaze (14 commits)")[![riki137](https://avatars.githubusercontent.com/u/1223388?v=4)](https://github.com/riki137 "riki137 (1 commits)")

---

Tags

static analysis

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

![Health badge](/badges/efabrica-phpstan-latte/health.svg)

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

###  Alternatives

[deptrac/deptrac

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

3.0k8.8M117](/packages/deptrac-deptrac)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2603.2M436](/packages/ssch-typo3-rector)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M92](/packages/shipmonk-dead-code-detector)

PHPackages © 2026

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