s1k3/livewire-v4-patch
Dev-only Laravel tool to convert Livewire v4 class components into Model-Focused Components (MFC). Provides an Artisan command to convert single components or whole folders, with options to keep originals, generate JS/CSS, exclude directories, and disable Pint formatting.
class_component_path, mfc_component_path) and exclusion rules (excluded_directories) allow customization for monorepos or modular architectures.composer require --dev installation ensures it doesn’t bloat production.convert-class-to:mfc command enables selective migration (e.g., one component at a time).create_js, create_css, and global_css introduce variability. Risk: Poorly configured CSS/JS generation could lead to duplicate or missing assets. Mitigation: Test with a subset of components first; use global_css=false (default) to avoid conflicts.__get). Risk: The package might not preserve all stateful logic during conversion. Mitigation: Validate converted components against test suites or manual QA.blade templates.)resources/views/components/ conventions.require-dev, ensuring it doesn’t affect production builds.app/Livewire/).app/Livewire/ directory.php artisan convert-class-to:mfc app/Livewire/ExampleComponent.php
public $property) persists.@livewire('components.example')).excluded_directories config to skip legacy components.find app/Livewire -name "*.php" | xargs artisan convert-class-to:mfc).@deprecated docs).@livewire directives use the new component paths (e.g., components.example instead of livewire:example).create_css=true, ensure the build process (e.g., Vite/Webpack) picks up new files.global_css mode if using shared styles.composer require --dev s1k3/livewire-v4-patch
php artisan vendor:publish --provider="LivewireV4\LivewireV4PatchServiceProvider"
config/livewire-v4-patch.php:
class_component_path and mfc_component_path.create_js/create_css initially to avoid asset issues.composer.json until stability is confirmed.livewire-v4-patch.php config may need updates if paths or exclusions change. Mitigation: Document defaults and changes in a CONTRIBUTING.md.ExampleComponent.php + example.blade.php).--verbose for artisan command output.public properties and methods.memory_limit.app/Livewire/ from backup if issues arise.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Conversion corrupts component | Broken UI/state loss | Backup before conversion; test incrementally. |
| CSS/JS generation conflicts | Duplicate or missing assets | Disable generation (create_css=false) initially. |
| Livewire v4 breaking changes | Package becomes incompatible | Pin package version; monitor Livewire updates. |
| Team resistance to MFCs | Slow adoption | Highlight benefits (e.g., easier testing). |
| Missing state in converted MFCs |
How can I help you explore Laravel packages today?