- How do I install MagicPro in a Laravel project?
- Run `composer require dixipro/magicpro` in your project directory. The package auto-discovers Laravel and requires no manual service provider registration. Verify installation by checking the `config/magicpro.php` file for default settings.
- Which Laravel versions does MagicPro support?
- MagicPro is designed for Laravel 9.x and 10.x. Check the package’s `composer.json` for exact version constraints, and ensure your project’s `laravel/framework` dependency aligns with the supported range.
- Can I use MagicPro for multi-step forms or client-side state management?
- MagicPro doesn’t natively support multi-step forms or client-side state (e.g., React/Vue stores). For these cases, use Laravel sessions or a frontend framework’s state management alongside MagicPro’s server-side logic.
- How do I secure forms with CSRF protection and rate limiting?
- MagicPro doesn’t include built-in CSRF protection, so rely on Laravel’s `VerifyCsrfToken` middleware. For rate limiting, use Laravel’s `throttle` middleware or implement custom logic in your form handlers.
- Does MagicPro work with API-driven frontend frameworks like React or Vue?
- Yes, MagicPro generates RESTful endpoints for forms, making it ideal for headless Laravel apps. Use the API to submit data from React/Vue components while leveraging MagicPro’s validation and schema logic server-side.
- How do I handle conditional logic (e.g., showing fields based on user input)?
- MagicPro supports conditional logic via schema definitions in your config. Use nested schemas or dynamic field toggling to show/hide fields based on runtime conditions, like user selections or roles.
- What’s the performance impact of large schemas (e.g., 100+ fields)?
- Schema parsing overhead depends on complexity, but MagicPro avoids heavy dependencies. For high-traffic forms, cache schemas in memory (e.g., `Cache::remember`) or use Laravel’s queue system to offload processing.
- How do I test dynamic form logic in PHPUnit?
- Mock the `$form->method()` calls using PHPUnit’s partial mocking or create test doubles for form instances. For schema validation, test individual rules separately and verify API responses match expected structures.
- Are there alternatives to MagicPro for Laravel form handling?
- Consider **Laravel Nova** for admin panels, **FilamentPHP** for customizable forms, or **Livewire** for reactive frontend integration. MagicPro stands out for API-first use cases and config-driven schemas but lacks community support.
- How do I customize form styling to match my design system (e.g., Tailwind)?
- MagicPro generates Blade templates by default, but you can override them by publishing assets (`php artisan vendor:publish --tag=magicpro-views`) and modifying the CSS/HTML. Use Tailwind’s utility classes or a custom CSS file.