- Can I use spiral/twig-bridge in a Laravel project to replace Blade?
- No, this package is designed for Spiral Framework, not Laravel. It introduces Spiral’s dependency injection and middleware systems, which conflict with Laravel’s native architecture. For Twig in Laravel, use the official `twig/twig` package with Laravel’s service providers instead.
- What Laravel versions does spiral/twig-bridge support?
- This package does not officially support Laravel. It’s built for Spiral Framework and requires Spiral’s core dependencies, which are incompatible with Laravel’s container, middleware, and event systems. No Laravel-specific versioning or optimizations exist.
- How do I install spiral/twig-bridge in Laravel?
- You can install it via Composer (`composer require spiral/twig-bridge`), but it won’t integrate natively with Laravel. You’d need to manually bridge Spiral’s container and middleware to Laravel’s systems, which is complex and unsupported. This is not recommended for production.
- Does spiral/twig-bridge offer better Twig performance than twig/twig in Laravel?
- There’s no evidence this package improves performance for Laravel. Spiral’s Twig adapter adds overhead from its dependency injection and middleware layers, which Laravel doesn’t use. For raw Twig performance, stick with `twig/twig` and Laravel’s built-in service providers.
- Can I use custom Twig extensions with spiral/twig-bridge in Laravel?
- Yes, but only if you’re willing to adopt Spiral’s dependency injection system. The package allows adding extensions via `TwigEngine` or `TwigBootloader`, but integrating this into Laravel’s container requires custom workarounds. Laravel’s native Twig support handles extensions more seamlessly.
- What are the risks of using spiral/twig-bridge in a Laravel app?
- High risks include architectural conflicts (container, middleware, events), dependency bloat from Spiral’s core, and lack of maintenance for Laravel. The package’s CI updates don’t address Laravel compatibility, and the project shows no signs of evolving to support Laravel.
- Are there alternatives to spiral/twig-bridge for Twig in Laravel?
- Yes. Use the official `twig/twig` package with Laravel’s service providers for native integration. For advanced Twig features, explore `laravel-twig` or build custom service providers. These avoid Spiral’s incompatibilities entirely.
- How do I configure spiral/twig-bridge for lazy loading in Laravel?
- Lazy loading is possible via `TwigBootloader`, but it still requires Spiral’s container. In Laravel, you’d need to manually resolve Spiral’s dependencies, which isn’t straightforward. Laravel’s service providers handle lazy loading natively without Spiral’s overhead.
- Is spiral/twig-bridge actively maintained for Laravel?
- No. The package is maintained for Spiral Framework, with minimal CI updates that don’t address Laravel. The project lacks Laravel-specific documentation, contributors, or roadmap items for Laravel support. It’s not a viable long-term choice for Laravel apps.
- Can I migrate from spiral/twig-bridge to twig/twig in Laravel?
- Yes, but you’d need to rewrite Spiral-specific configurations (e.g., bootloaders) to use Laravel’s service providers. The transition is complex due to architectural differences, but it’s the only sustainable path for Laravel compatibility.