Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Twig Extension

Twig Extension Laravel Package

puli/twig-extension

Twig extension for Puli that resolves Twig templates through Puli's resource repository. It integrates Puli path and resource lookups with Twig's loader, letting template names be discovered and rendered from Puli-managed packages and paths.

Deep Wiki
Context7

puli/twig-extension integrates Puli resource paths with Twig, letting templates be referenced by logical paths (e.g. @app/templates/index.html.twig) instead of hard-coded filesystem locations. It hooks into Twig's loading mechanism so the Puli repository resolves each template path at render time, keeping references portable across deployments and independent of the physical directory layout.

  • Resolves Twig templates through Puli's resource repository
  • Supports namespaced paths such as @vendor/package/...
  • Plugs into existing Twig environments with minimal configuration
  • Keeps template references stable when files move
  • Complements Puli's discovery for reusable package templates
Frequently asked questions about Twig Extension
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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource