canvural/larastan-strict-rules
Extra strict, opinionated PHPStan rules for Laravel via Larastan. Enforce safer patterns by banning dynamic where methods, facades, and global helpers; prevent validation in controllers; ensure scopes return Eloquent Builder. Enable all at once or toggle rules individually.
NoFacadeRule and NoGlobalLaravelFunctionRule help mitigate hidden dependencies and runtime errors, aligning with security-focused roadmaps.ScopeShouldReturnQueryBuilderRule ensure efficient query building, supporting performance-focused initiatives.Adopt if:
Look elsewhere if:
"This package automates Laravel best practices enforcement via PHPStan, reducing bugs, improving code consistency, and accelerating onboarding. By adopting strict rules (e.g., no facades, no dynamic queries), we’ll cut technical debt, enhance security, and align with scalable architecture—all while requiring minimal upfront effort. It’s a low-cost, high-impact way to future-proof our codebase."
Key Outcomes: ✅ Faster onboarding (clearer conventions). ✅ Fewer production bugs (catches issues early). ✅ Lower maintenance costs (consistent patterns). ✅ Scalable architecture (avoids anti-patterns).
"This adds Laravel-specific PHPStan rules to catch anti-patterns like facades, dynamic queries, and validation in controllers—automatically. You can enable rules incrementally (e.g., start with NoFacadeRule), and it integrates seamlessly with your existing static analysis pipeline. It’s opinionated but configurable, so you’re not locked into every rule."
Why It Matters:
🔹 Reduces cognitive load: No more debating "should we use facades here?"
🔹 Catches edge cases: Finds bugs like return false in event listeners before they hit prod.
🔹 Future-proofs code: Enforces patterns that scale (e.g., proper query builder usage).
🔹 Low friction: Works with your existing PHPStan/Larastan setup—just include rules.neon.
Call to Action:
"Let’s pilot this in the next sprint—start with 2–3 rules (e.g., NoFacadeRule + ListenerShouldHaveVoidReturnType) and measure the impact on code quality and developer velocity."
How can I help you explore Laravel packages today?