- Can I use this bundle with Laravel’s Blade templates instead of Twig?
- No, this bundle requires Twig templates. For Blade, you’d need to either switch to Twig for filtered sections or create a custom Blade directive that proxies to Twig’s `apply_filter()`. The bundle doesn’t natively support Blade.
- How do I restrict dynamic filters to prevent security risks like RCE?
- The bundle doesn’t enforce whitelisting by default, but you can extend it by overriding the `apply_filter` logic in a custom Twig extension. Validate filter names against a predefined list (e.g., `['upper', 'lower', 'trim']`) before processing to block unauthorized filters.
- Will this bundle work with Laravel 10 or 11? What about older versions?
- It officially requires **PHP 8.5+** and Symfony 8.0+, which aligns with Laravel 10/11+. Older Laravel versions (e.g., LTS on PHP 8.1) may need Docker/Valet updates or won’t work due to PHP version constraints. Test thoroughly in your environment.
- Does this bundle integrate with Laravel’s service container or caching (e.g., Blade caching)?
- No, it’s a standalone Twig extension with no native Laravel service provider. You’ll need to manually configure Twig’s environment (e.g., via `symfony/twig-bridge`) and may encounter conflicts with Laravel’s caching layer. Monitor template performance if using dynamic filters heavily.
- What’s the performance impact of dynamic filters compared to static Blade directives?
- Dynamic filters add runtime overhead for resolving and applying filters, which can slow down high-traffic templates. For large datasets (e.g., filtering arrays with 10K+ items), consider pre-filtering data in PHP or using Laravel’s `collect()->pipe()` instead of Twig.
- Are there alternatives for simple filter chaining in Laravel without Twig?
- Yes. For minimal use cases, implement a custom Blade directive (e.g., `@applyFilter('max', $array)`) or use Laravel helpers like `Str::upper()`, `Arr::pluck()`, or `collect()->pipe()`. These avoid Twig’s setup complexity but lack dynamic runtime flexibility.
- How do I install this in Laravel? Does it conflict with existing Twig setups?
- Install via Composer (`composer require danilovl/apply-filter-twig-extension-bundle`) and register the bundle in `config/bundles.php`. Ensure you have `symfony/twig-bridge` and `tightenco/ziggy` for Twig support. Conflicts are unlikely if Twig is already configured, but test in a staging environment first.
- Can I use this bundle for complex filter pipelines (e.g., custom PHP callbacks)?
- No, the bundle is designed for built-in PHP/Twig filters (e.g., `upper`, `max`). For custom logic, pre-process data in PHP or use Laravel’s `collect()` methods. The bundle doesn’t support arbitrary PHP callbacks or complex pipelines.
- Is this package actively maintained? Who should I contact for issues?
- The last release appears to be from 2023/24 (likely a typo in the README), and there’s no active maintenance indicated. Open GitHub issues for support, but expect limited responses. Consider forking or wrapping it in a Laravel-specific package if critical.
- How do I test this bundle in a Laravel project before production?
- Start with a proof-of-concept: set up Twig in Laravel using `symfony/twig-bridge`, test basic filters (e.g., `apply_filter('upper', 'text')`) in non-critical templates, and validate performance with tools like Tideways/XHProf. Avoid dynamic filters in production until thoroughly tested.