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 Exception

Twig Exception Laravel Package

kwrz/twig-exception

Integrates Twig with Laravel's exception handler so errors and debug pages render through Twig templates instead of Blade, keeping error output consistent with your Twig-based views and making custom error pages easy to style.

View on GitHub
Deep Wiki
Context7

Use to make customizables Twig exception pages for routes or specific HTTP status codes

Frequently asked questions about Twig Exception
What is kwrz/twig-exception used for in Laravel?
kwrz/twig-exception lets Laravel render exception and error pages through Twig templates instead of Blade. It is aimed at applications that already use Twig for normal views and want custom error pages for specific routes or HTTP status codes. It does not replace Laravel's exception handler on its own; you need to wire it into the exception rendering path.
Does kwrz/twig-exception work in a standard Blade-based Laravel application?
Not natively. Laravel's exception flow is built around App\Exceptions\Handler, render and renderable hooks, middleware, and Blade views, so this package introduces a parallel Twig rendering path. It only makes sense if your app already uses Twig as a first-class engine, typically via something like twigbridge, or if you are prepared to build an adapter.
Which Laravel and PHP versions are supported by kwrz/twig-exception?
The package context does not document supported Laravel or PHP versions, and its weak adoption means you must verify compatibility yourself. Check the composer.json constraints for PHP, Twig, and Laravel, then run a time-boxed spike on your target versions. Do not assume current Laravel or Twig 3 support without testing.
How do I install kwrz/twig-exception with Composer?
Install it with composer require kwrz/twig-exception after confirming the version constraints match your PHP, Twig, and Laravel versions. Then wire the package into Laravel's exception handler or a middleware fallback rather than assuming it hooks in automatically. Publish or create any required configuration for route-specific and status-code mappings, and test with a non-production branch first.
How do I create custom Twig error pages for specific HTTP status codes or routes?
The package is intended to map routes or specific HTTP status codes to Twig exception templates. Configure those mappings in the package config or adapter layer, and keep Laravel's handler as the decision-maker for status codes. Test 403, 404, 419, 429, and 500 responses, and make sure a missing or broken Twig template falls back to Laravel's default error page.
Can kwrz/twig-exception preserve JSON responses for API requests?
That is not guaranteed by the package context, so you should not route API errors through Twig blindly. Keep Laravel's exception handler responsible for content negotiation and only delegate HTML rendering to Twig when the request expects HTML. Add tests that send Accept: application/json and confirm API clients still receive JSON error payloads.
How does kwrz/twig-exception integrate with Laravel's App\Exceptions\Handler?
It requires an adapter layer. Laravel's native flow centers on App\Exceptions\Handler, render(), renderable(), middleware, and Blade, and this package is Twig-oriented rather than a drop-in Laravel exception handler. Use it only as an HTML rendering delegate behind your existing handler, and preserve Laravel's reporting, logging, and status-code decisions.
Is kwrz/twig-exception safe to use in production?
Treat it as high risk until you have reviewed it. The package has zero stars, zero dependents, and a score of 0, so there is little ecosystem validation, and unsafe exception-page behavior can leak stack traces or exception messages in production. Ensure debug mode is off, template path resolution is reviewed, failures fall back to Laravel defaults, and recursive rendering cannot loop.
What are better alternatives to kwrz/twig-exception for custom Laravel error pages?
In a Blade-first app, prefer Laravel-native resources/views/errors/{code}.blade.php, Handler::renderable(), or a small custom exception renderer. If you already standardize on Twig, use a maintained Twig bridge and implement exception rendering as a thin adapter. These options keep Laravel's exception lifecycle intact and avoid a parallel rendering path.
How should I test and maintain kwrz/twig-exception in a Laravel project?
Add tests for 403, 404, 419, 429, and 500 responses, API JSON requests, debug on and off, missing templates, and Twig rendering failures. Pin the package version, document an exit plan, and expect to fork, patch, or replace it because community support is effectively absent. Roll it out behind a feature flag or canary with rollback by config.
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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums