Download the PHP package drmovi/phpstan-laravel-module-boundaries without Composer
On this page you can find all versions of the php package drmovi/phpstan-laravel-module-boundaries. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drmovi/phpstan-laravel-module-boundaries
More information about drmovi/phpstan-laravel-module-boundaries
Files in drmovi/phpstan-laravel-module-boundaries
Package phpstan-laravel-module-boundaries
Short Description PHPStan extension to enforce Laravel module boundaries and prevent cross-module imports
License MIT
Informations about the package phpstan-laravel-module-boundaries
PHPStan Laravel Module Boundaries
A PHPStan extension that enforces module boundaries in Laravel applications to maintain bounded contexts and prevent unwanted cross-module dependencies.
Features
- Detects and prevents cross-module imports between Laravel modules
- Supports shared modules that can be imported by any module
- Configurable via Laravel project's
composer.json - Works with PHPStan 2.0+
Installation
Install the extension via Composer:
Configuration
1. Laravel Project Configuration
In your Laravel project's composer.json, add the following configuration:
laravel-module.path: The path to your modules directory relative to the project rootphpstan-laravel-module-boundaries.shared: Array of module names that are considered "shared" and can be imported by any module
2. PHPStan Configuration
The extension is automatically loaded when installed. No additional PHPStan configuration is required.
Rules
Module Boundary Rule
This rule enforces the following boundaries:
- Same Module: Files within a module can import from the same module ✅
- Shared Modules: Any module can import from modules listed in the
sharedconfiguration ✅ - Shared to Shared: Shared modules can import from other shared modules ✅
- Cross-Module: Non-shared modules cannot import from other non-shared modules ❌
Example
Given the following module structure:
With configuration:
Allowed Imports ✅
Forbidden Imports ❌
Error Messages
When a boundary violation is detected, PHPStan will report an error like:
Requirements
- PHP 8.4+
- PHPStan 2.0+
- Laravel project with modular structure
License
MIT License. See LICENSE file for details.