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

ActiveLibrary

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

0.19.0(5mo ago)4411.2k↓25%6[8 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.5CI passing

Since Nov 18Pushed 5mo 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 1mo ago

READMEChangelog (10)Dependencies (13)Versions (33)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

50

—

FairBetter than 96% of packages

Maintenance68

Regular maintenance activity

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 56% 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 ~44 days

Recently: every ~152 days

Total

26

Last Release

171d ago

PHP version history (4 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

### 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 (292 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

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[deptrac/deptrac

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

2.9k6.3M68](/packages/deptrac-deptrac)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

66766.6M1.1k](/packages/phpstan-phpstan-doctrine)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33320.0M375](/packages/spaze-phpstan-disallowed-calls)[ekino/phpstan-banned-code

Detected banned code using PHPStan

2925.6M92](/packages/ekino-phpstan-banned-code)

PHPackages © 2026

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