PHPStan for latte on a slim framework

Hello,

I’m new to slim, and I decided to give it a try with the latte template engine following this guide: Slim 4 - Latte Template Engine | Daniel Opitz - Blog
I’m looking for a way to add latte validation to PHPStan, I wish to validate if the template name is valid and if all the variables are present.

I found the package efabrica/phpstan-latte that should be doing exactly this, but it seem to be created with the nette application framework in mind.
I only managed to get this error: “:-1 Latte template home.latte was not analysed.” even if I’m calling the home.latte template, PHPStan does not seem to recognize it.

Has anybody managed to make this extension work with php slim? Or maybe know an other extension to validate latte file?

Thank you

I guess the efabrica/phpstan-latte package works only in combination with the Nette framework because it is looking for a Nette specific template renderer.

See here:

PS: Have you tried this?

Hi there,
On the Nette Framework forum I manage to get in touch with 2 of the creator of the PHPStan plugins, and they were a lots of help.
I’ll leave my repo up with their PR in case other people want to have better validation on their latte template.

By the way, side question, any plans for book 3?

Thanks

Ok, great.

By the way, side question, any plans for book 3?

Yes, my plan is to write the 3rd book for Slim. I’m still collecting new ideas at the moment and I think I’ll release it within this year.