- Can I use Memio Linter to validate Eloquent models in Laravel without adopting Memio’s full ecosystem?
- No, this package is tightly coupled to Memio’s model system. Eloquent models won’t work without rewriting constraints to target Laravel’s reflection system or custom model traits, which isn’t supported out of the box.
- What Laravel version does Memio Linter support?
- The package requires PHP 7.2+, which aligns with Laravel 8+. However, its constraints are designed for Memio’s models, not Laravel’s Eloquent, so version compatibility alone doesn’t guarantee usability.
- How do I install Memio Linter in a Laravel project?
- Run `composer require memio/linter:^3.0`, but note this only installs the constraints. You’ll also need Memio’s validator and model layers to use it, which aren’t Laravel-native.
- Are there alternatives to Memio Linter for Laravel model validation?
- Yes. For static analysis, use PHPStan or Psalm with custom rules. For runtime validation, leverage Eloquent’s built-in rules or Laravel’s Form Request validation. Memio Linter’s constraints would need significant adaptation to fit Laravel.
- Can I integrate Memio Linter into Laravel’s CI/CD pipeline?
- Integration is possible but complex. You’d need custom scripts to bridge Memio’s validation system with Laravel’s workflows (e.g., GitHub Actions), and it requires adopting Memio’s tooling like Docker and phpspec.
- What constraints does Memio Linter enforce that PHPStan/Psalm might miss?
- Constraints like `MethodCannotBeAbstractAndHaveBody` or `ContractMethodsCanOnlyBePublic` are opinionated checks for Memio’s model contracts. PHPStan/Psalm can replicate these with custom rules, but they’re not natively supported.
- Will Memio Linter work with custom Laravel model layers (e.g., DTOs, API resources)?
- Only if you rewrite constraints to target your custom model classes instead of Memio’s `Model` interface. This requires manual effort and isn’t plug-and-play.
- Does Memio Linter support runtime validation like Laravel’s Form Requests?
- No, it’s designed for build-time validation via Memio’s code generation pipeline. Laravel typically uses runtime validation (e.g., Eloquent rules) or static analysis tools like PHPStan.
- What’s the overhead of adopting Memio Linter in a Laravel project?
- High. It introduces dependencies like Docker, PHPStan, Rector, and phpspec, which may conflict with Laravel’s simpler toolchain (e.g., `phpstan:baseline`, `pint`). Onboarding friction is significant unless you’re already using Memio.
- Can I extract individual constraints (e.g., `MethodCannotBeAbstractAndHaveBody`) for Laravel?
- Technically yes, but you’d need to rewrite them to use Laravel’s reflection utilities or custom traits. This could duplicate effort if similar checks already exist in PHPStan/Psalm.