nowo-tech / fragment-kit-bundle
Symfony bundle: resilient Twig fragment rendering with optional fallback template and Sentry reporting.
Package info
github.com/nowo-tech/FragmentKitBundle
Type:symfony-bundle
pkg:composer/nowo-tech/fragment-kit-bundle
Requires
- php: >=8.2 <8.6
- symfony/config: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/framework-bundle: ^7.4 || ^8.0
- symfony/http-foundation: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/twig-bundle: ^7.4 || ^8.0
- symfony/yaml: ^7.4 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
- sentry/sentry-symfony: ^5.0
- symfony/browser-kit: ^7.4 || ^8.0
- symfony/phpunit-bridge: ^7.4 || ^8.0
Suggests
- sentry/sentry-symfony: Report suppressed fragment failures to Sentry without breaking the parent page.
- symfony/flex: For automatic recipe installation (config and bundles.php)
README
⭐ Found this useful? Give it a star on GitHub! It helps us maintain and improve the project.
Symfony bundle that makes Twig fragment sub-requests resilient when using {ignore_errors: true}.
Features
- ✅ HTTP error tolerance —
{ignore_errors: true}also covers 403/404 (not only exceptions) - ✅ Twig fallback — configurable template (or empty string)
- ✅ Optional Sentry — report suppressed failures without breaking the parent page
- ✅ Flex recipe — ships
nowo_fragment_kitconfig - ✅ FrankenPHP demo — Symfony 8 single-container demo
FrankenPHP: Demos use a single PHP service (FrankenPHP, no nginx). With APP_ENV=dev (default), the Docker entrypoint swaps in Caddyfile.dev — php_server without workers for local development. The production Caddyfile can use php_server { worker … }; see docs/DEMO-FRANKENPHP.md.
Problem
{{ render(controller(...), {ignore_errors: true}) }} only suppresses exceptions thrown during sub-requests. When the sub-request returns an HTTP error status (403, 404, …), FragmentHandler::deliver() throws a RuntimeException and the parent page still fails with a 500.
Installation
composer require nowo-tech/fragment-kit-bundle
Register the bundle (Flex does this automatically):
Nowo\FragmentKitBundle\NowoFragmentKitBundle::class => ['all' => true],
{{ render(controller('App\\Controller\\WidgetController::index'), {ignore_errors: true}) }}
Requirements
- PHP
>= 8.2,< 8.6 - Symfony
^7.4 || ^8.0(CI covers 7.4, 8.0, 8.1) - Twig Bundle
Documentation
- GitHub Actions CI requirements
- GitLab CI (REQ-GIT-001 mirror)
- Installation
- Configuration
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
Additional documentation
- Demo with FrankenPHP (includes worker mode)
- Server cookbook (Nginx, php-fpm, FrankenPHP)
Version information
| Version | PHP | Symfony | Status |
|---|---|---|---|
| 1.0.x | >= 8.2 | 7.4 – 8.1+ | Stable |
Demos
make -C demo up-symfony8 # http://localhost:8050 (default PORT)
Tests and coverage
make test
make test-coverage
- Tests: PHPUnit (unit + integration)
- PHP: 100% lines (
make test-coverage)
Development
make setup-hooks make up make install make release-check
License
MIT — see LICENSE.