suin/phpcs-psr4-sniff
suin/phpcs-psr4-sniff is a PHP_CodeSniffer sniff that validates PSR-4 autoloading rules, flagging namespace, directory, and filename mismatches so Composer autoloading stays reliable in Laravel and other PHP projects.
psr-4-dev paths). At 27 stars and a single-purpose scope, this is a low-risk dependency that buys an afternoon of engineering time back and avoids owning bespoke tooling.Consider adoption when:
Class not found failures at runtime.Look elsewhere, or handle differently, when:
composer dump-autoload -o) with strict PSR-4 checks, and static analyzers such as PHPStan and Psalm flag unresolvable classes. If the team already runs a strict static analysis baseline, this sniff may be redundant. Evaluate overlap before adding a rule.To executives: This is a small, free, open-source add-on to a tool our engineers already use. It automatically blocks a specific category of mistake — code files whose location doesn't match their declared namespace — before it reaches production. Those mistakes cause autoload failures that are confusing to debug and occasionally cause outages on deploy. Cost is negligible: a config line and a few hours of setup. The main caveat is that the project hasn't been updated since 2021, so engineering will validate compatibility first. Frame it as cheap insurance on deployment reliability, not a strategic investment.
To engineering: We add one PHP_CodeSniffer sniff that enforces PSR-4 path/namespace agreement across all our autoload roots. It's a small, single-purpose package — worth adopting instead of maintaining a homegrown sniff, but we should confirm PHPCS compatibility given the 2021 last release, and we should decide whether our existing static analysis already covers this. Expect a one-time triage of pre-existing violations before we can flip it to blocking; run it in report-only mode on the current branch first so the diff doesn't land as noise in an unrelated pull request.
How can I help you explore Laravel packages today?