Add an example of a simple phpstan.neon file in the README#2744
Add an example of a simple phpstan.neon file in the README#2744ondrejmirtes merged 1 commit intophpstan:masterfrom
Conversation
Can you describe your struggles? There's no configuration file needed by default. If you don't need to ignore any errors and you autoload everything via Composer, you don't need any configuration on the lower levels. README sections each describe a specific problem and there's a lot of config file examples already. But I'm not dismissing that you had problems, I just want the feedback :) |
|
Sure, the thing is that when you use PHPStan you have to make at least 2 choices: which level, and which directories to analyze. If I don't hardcode those anywhere, then everyone on the team might be doing something different. This is why I always create config files: phpcs, php-cs-fixer, etc. The goal is to be able to simply run the tool without argument/option and it just works. That has also the advantage of being much simpler (but the main reason is consistency). So I wanted to create a PHPStan config file, but here were the steps:
All of these can be solved with the current README, but each information is separated from the others. Also, most of this information requires reading a full sentence of paragraph each time: I think this could be improved with a single code example. It's fine if advanced options are harder to read (because they require more explanations), but I think that making the default setup more obvious could be helpful to get started. |
|
To illustrate what I mean, I've opened #2746 Since you mentioned it, this is exactly something that I missed when I read the README quickly. Then I read it again slowly and picked that up. Hopefully, with a simpler sentence, it's easier to see at a glance. I also think this could be improved further by reordering maybe: put the most important information first, then the advanced use cases later. The README is pretty huge, so I think it's hard to expect first-time users to read it all in one shot just to get started. Anyway, those are just suggestions of course ^^ My experience is not necessarily the same for everyone. |
| ## Configuration | ||
|
|
||
| Config file is passed to the `phpstan` executable with `-c` option: | ||
| A config file can passed to the `phpstan` executable using the `-c` option: |
There was a problem hiding this comment.
can be - be is missed
|
Maybe I'm stupid, but I really need this PR. I wanted to setup So I updated my config: And nope! I really don't want to be annoying with this, but I think making things dead simple is good. I'm pretty sure I could have avoided this by actually reading more of the README. I didn't though, and I think some other users don't as well. |
|
I suggest linking this as well. It was particularly useful to me when I needed some of the more arcane config options. |
|
Hi, sure, no problem. I'm so used to nette/di that I just automatically know where to put the config options :) |
Followup for phpstan#2744
|
I hope this is sufficient and understandable :) https://phpstan.org/config-reference |
|
Ohhh yeahhhh 🔥 that is super useful! Thank you! |



I struggled a lot getting started with PHPStan because I couldn't find a simple example of a "default"
phpstan.neon.I added one in the README (in the future I may look in a
phpstan initcommand because I think that would be even better).