- Can I use MremiContactBundle in a **pure Laravel** project without Symfony dependencies?
- No, this bundle is Symfony2-specific and requires Symfony components like Validator, Translation, and Twig. For Laravel, consider native alternatives like **spatie/laravel-contact** or **beberlei/fluent-bundle** to avoid dependency bloat. If you must use it, you’d need to bridge Symfony services (e.g., symfony/validator) into Laravel manually.
- How do I **install this bundle in Laravel** if my project uses Symfony components?
- Run `composer require mremi/contact-bundle`, then register the bundle in `config/app.php` under `config['bundles']` (if using Symfony Flex) or manually in `AppKernel.php`. Ensure Symfony’s `translator`, `validator`, and `twig` components are also installed and configured. For routing, import the bundle’s YAML routes into Laravel’s `routes/web.php`.
- Does this bundle support **Laravel’s Eloquent ORM** instead of Doctrine?
- No, the bundle assumes Doctrine ORM by default. To use Eloquent, you’ll need to create a custom storage adapter or override the bundle’s `Contact` entity to work with Eloquent models. Alternatively, store submissions in a flat table or use Laravel’s native database layer without the bundle’s ORM features.
- How do I **replace Twig templates** with Laravel Blade?
- The bundle’s templates are Twig-based, so you’ll need to manually convert them to Blade or use a Twig bridge like `tightenco/ziggy` + `twig/extra-bundle`. Replace the `Resources/views/` templates in the bundle with Blade equivalents, ensuring paths and logic (e.g., `{{ form_start() }}`) are adapted to Blade syntax like `@formStart`.
- What **Laravel versions** or Symfony components does this bundle require?
- This bundle requires **Symfony 2.3+**, which may conflict with Laravel’s native systems (e.g., Laravel’s Validator vs. Symfony’s). For Laravel 8/9, test compatibility with Symfony 5/6 components like `symfony/validator` and `symfony/translation`. Avoid mixing versions unless you’re using a hybrid Symfony/Laravel stack.
- How do I **customize the contact form fields** or validation rules?
- Use Symfony’s FormBuilder configuration in `config.yml` or override the bundle’s form type class. For validation, extend the bundle’s `ContactType` or create a custom form request in Laravel. Example: Add `validation: { name: 'required|max:255' }` to the bundle’s config or override the `validate()` method in a Laravel Form Request.
- Can I **send emails** from this bundle without Symfony Mailer?
- Yes, but you’ll need to replace Symfony’s `Swiftmailer` with Laravel’s `Mail` facade. Override the bundle’s email service or create a custom handler in Laravel’s `app/Providers/AppServiceProvider` to intercept and forward submissions to Laravel’s mail system using `Mail::send()`.
- What are the **alternatives** to this bundle for Laravel?
- For Laravel, consider **spatie/laravel-contact** (lightweight, Eloquent-friendly), **beberlei/fluent-bundle** (form handling), or **laravel-share/laravel-contact** (simple form + email). If you need Symfony features, **laravel-symfony-bridge** packages (e.g., `spatie/laravel-symfony-mailer`) can integrate Symfony components without full bundle adoption.
- How do I **test this bundle** in a Laravel environment?
- Mock Symfony dependencies (e.g., `symfony/validator`) using Laravel’s `Mockery` or `PHPUnit`. Test form submission routes with `Http::post()`, validate responses, and assert database entries (if using Eloquent). For Twig templates, use Blade stubs or a testing bridge like `orchestra/testbench` to simulate Symfony components.
- Will this bundle work in **production** with Laravel’s caching or queue systems?
- The bundle itself doesn’t integrate with Laravel’s caching or queues, but you can wrap its logic in Laravel’s `Cache` or `Queue` facades. For example, defer email sending with `Mail::later()` or cache form submissions in `Cache::remember()`. Ensure Symfony’s components (e.g., `translator`) are also cache-compatible in your hybrid setup.