CodeIgniter Forums
which linter to use (and how to setup)? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: which linter to use (and how to setup)? (/showthread.php?tid=92783)



which linter to use (and how to setup)? - dilawar - 04-23-2025

Hi,
I am using codeigniter4 (first time). At work, I used laravel based project with a very good psalm support.

I am struggling to get psalm to work with ci4 -- out of box. A lot of errors are being thrown -- most of which is about missing functions and classes!
I tried tweaking settings a bit but I didn't get far.

Before I spend more time "having fun" fixing it, I was wondering if there is a tutorial/library that allows me to integrete psalm (or any other linter)?

In other words -- what is the recommended way to lint ci4 project?
best,
  Dilawar


RE: which linter to use (and how to setup)? - ManceJoan - 05-18-2025

Hi Dilawar,
You're definitely not alone—Psalm can be tricky with CodeIgniter 4 due to how CI4 structures its services and uses magic methods. A lot of the missing function/class issues stem from that.

While there's no official support, some developers use PHPStan instead, since it handles dynamic code a bit better. For Psalm, you might have to create stub files or use ignoreIssueForFile pragmas to suppress false positives.

Setting a baseline with psalm --init and then selectively tweaking it has worked for some. Also, excluding the system/ folder from scanning helps reduce noise.

If you're not tied to Psalm, PHPStan with a custom config may get you linting faster with less hassle.

Hope this helps!


RE: which linter to use (and how to setup)? - paulbalandan - 05-19-2025

You can try using the bootstrap file specifically for psalm. Look at https://github.com/codeigniter4/CodeIgniter4 then check psalm_autoload.php