- How do I install puli/twig-extension in a Laravel project?
- Install it with Composer using composer require puli/twig-extension. Because it is a Twig extension rather than a Laravel package, you also need a Twig integration such as TwigBridge or a custom service provider to register Twig in Laravel. Then register the Puli Twig extension with the Twig environment and configure the Puli repository.
- What does puli/twig-extension actually add to Twig?
- It integrates Puli resource paths with Twig so templates can resolve resources through Puli's repository instead of hard-coded filesystem paths. It provides Twig functions and filters for Puli path resolution. This helps keep template asset references portable across environments.
- Is puli/twig-extension compatible with Laravel's Blade templates?
- No, it is a Twig extension and does not add features to Blade. In Laravel you would need to use Twig as your templating engine, typically through a package like TwigBridge, and register the extension there. Blade users should use Laravel's native helpers or a custom Blade directive instead.
- Which Laravel versions support puli/twig-extension?
- The package itself does not declare Laravel-specific version support because it targets Twig and Puli. Laravel compatibility depends on the Twig integration package and the PHP and Twig versions your application uses. Check Composer constraints for puli/twig-extension, Twig, and your Laravel Twig bridge before upgrading.
- How do I configure Puli paths for Twig in Laravel?
- Configure a Puli repository with the resource paths your templates need, then pass that repository into the Puli Twig extension when registering it with Twig. In Laravel, this usually happens in a service provider that builds the Twig environment. Keep path mappings in configuration rather than hard-coding them in templates.
- Can I use Puli path resolution inside Twig includes and extends?
- Puli path resolution is exposed through Twig functions and filters, so you can use it where Twig allows expressions, such as asset URLs or dynamic include paths if your loader supports them. For include and extends, the resolved path must still be loadable by the Twig loader. Verify your Twig loader is configured to read from the Puli-backed location.
- How should I test templates that use puli/twig-extension?
- Render templates in a test Twig environment with the Puli extension registered and a test Puli repository containing fixture resources. Assert that the generated output contains the expected resolved paths. Mock or use an in-memory repository where possible to keep tests fast and isolated.
- What are common production concerns with Puli and Twig?
- Make sure Puli's repository is built and available in production, and avoid relying on development-only filesystem paths. Cache Twig templates and warm Puli path mappings during deployment if your setup supports it. Also confirm that resolved paths are web-accessible or correctly passed through your asset pipeline.
- What alternatives exist to puli/twig-extension?
- For Twig-only projects you can use Twig's native loader paths and namespaces instead of Puli. In Laravel, Blade plus asset helpers or a TwigBridge setup with configured paths may be simpler. Symfony projects often use Puli bundles or Symfony's own asset and finder components.
- Is puli/twig-extension actively maintained and safe for long-term Laravel projects?
- The package is a small Puli Twig integration, and its repository information is not provided here, so check Packagist and the source repository for recent releases and issue activity. The broader Puli project has seen reduced activity, so evaluate whether native Twig loader paths meet your needs. For long-term Laravel projects, prefer a maintained Twig integration and pin compatible Composer versions.