modules:sync command automatically updates your project’s configuration files to include all registered modules, ensuring your IDE and testing tools properly recognize module code.
Usage
Options
Skip updating PhpStorm configuration files.Use this if you don’t use PhpStorm or want to prevent IDE config changes.
What It Does
The command synchronizes multiple configuration files:1. PHPUnit Configuration
Updatesphpunit.xml to include module tests:
- Adds a “Modules” test suite
- Configures directory pattern:
./app-modules/*/tests - Sets test suffix to
Test.php
2. PhpStorm Laravel Plugin Config
Updates.idea/laravel-plugin.xml to:
- Register module view directories
- Configure module namespace roots
- Enable Laravel features for modules
3. PhpStorm PHP Config
Updates.idea/php.xml to:
- Add module source directories to PHP include paths
- Configure PSR-4 namespace mappings
- Enable autocompletion for module classes
4. PhpStorm Workspace Config
Updates.idea/workspace.xml to:
- Register module library roots
- Configure resource directories
- Set up module-specific settings
5. PhpStorm Project IML
Updates.idea/*.iml to:
- Mark module
src/directories as source folders - Mark module
tests/directories as test sources - Configure resource roots for views and assets
Example Output
Skip PhpStorm Updates
Already Synced
The command only modifies files that exist and need updates. Missing configuration files are safely skipped with informational messages.
When to Use
Runmodules:sync in these scenarios:
After Creating First Module
Initial setup for module testing and IDE support:After Adding Multiple Modules
Ensure all modules are properly configured:After Cloning Repository
Set up IDE configuration for new team members:IDE Not Recognizing Modules
Fix autocompletion and navigation issues:PHPUnit Configuration
Before Sync
After Sync
PhpStorm Integration
Benefits of PhpStorm Sync
After runningmodules:sync, PhpStorm provides:
Code Navigation
- Click through to module classes
- Find usages across modules
- Go to definition for module code
- Module class hints
- Method suggestions
- Namespace imports
- Safe rename across modules
- Extract method in module code
- Move classes between modules
- Run module tests from IDE
- Debug module test cases
- Coverage reports for modules
Manual Sync Alternative
If you prefer manual PhpStorm configuration:- Settings → Directories
- Mark
app-modules/*/srcas Sources - Mark
app-modules/*/testsas Tests
Verbose Output
Get detailed information about sync operations:Configuration Files Modified
The command may modify these files in your project:Version Control
Should You Commit IDE Files?
Recommended approach:- Team benefits from shared module configuration
- Consistent IDE behavior across developers
- New team members get working setup automatically
modules:sync after setup.
Troubleshooting
PHPUnit not finding module tests?
Problem:php artisan test doesn’t discover module tests.
Solution:
PhpStorm can’t find module classes?
Problem: Autocompletion and navigation not working for modules. Solution:Sync says “Cannot find testsuites node”?
Problem: Yourphpunit.xml has non-standard structure.
Solution: Ensure your phpunit.xml has a <testsuites> section:
PhpStorm config not updating?
Problem: Sync reports success but IDE still has issues. Solution:Team Workflow
Recommended workflow for teams:Initial Setup
After Adding Module
Best Practices
- Run after module changes - Always sync after adding/removing modules
- Commit IDE configs - Share configuration with team via version control
- Include in setup docs - Add to onboarding instructions for new developers
- Automate if possible - Add to post-install Composer scripts:
- Run before testing - Ensure test suite is up-to-date
Related Commands
- make:module - Create module (then sync configuration)
- modules:list - View modules that will be synced
- modules:cache - Cache modules after syncing
- modules:clear - Clear cache before syncing