sonata-project/twig-extensions
Provides a set of useful Twig extensions for Sonata projects, adding extra filters, functions, and helpers to enhance templates. Install via Composer and integrate with Twig to simplify common view tasks and formatting.
twig/laravel, but PHP 8.2+ is now required (dropping PHP 8.1 support). This may force upgrades for teams still on PHP 8.1.illuminate/support or symfony/http-foundation versions.symfony/options-resolver, symfony/string, or other components that Laravel already bundles, risking version mismatches.sonata_block) remain valuable for complex UIs.composer.json pull in conflicting Symfony 7.x components? Audit with:
composer why symfony/http-foundation
composer require php:^8.2 if upgrading.illuminate/support may already include compatible Symfony components, but test for conflicts.Phase 0: Pre-Upgrade Audit (New Step)
php -v
composer why symfony/http-foundation symfony/options-resolver
Phase 1: PHP/Symfony Upgrade (If Needed)
# Example for Ubuntu
sudo apt remove php8.1
sudo apt install php8.2
composer.json to enforce PHP 8.2:
"config": {
"platform": {
"php": "8.2.0"
}
}
composer update --with-all-dependencies
Phase 2: Twig Setup (Unchanged)
composer require twig/laravel sonata-project/twig-extensions:^2.6
config/view.php (ensure enabled: true).Phase 3: Incremental Adoption (Unchanged)
BlockService to resolve Symfony 8.x API changes (e.g., Stringable interface).auth or spatie/laravel-permission to replace Sonata’s Symfony-based security.| Priority | Task | Dependencies | New Considerations |
|---|---|---|---|
| 0 | PHP 8.2 Upgrade | N/A | Critical for this release |
| 1 | Symfony Dependency Audit | composer why |
Check for conflicts |
| 2 | Set up Twig in Laravel | twig/laravel, PHP 8.2+ |
|
| 3 | Test basic extensions | Sonata’s sonata_block |
|
| 4 | Migrate critical templates | Blade-to-Twig conversion scripts | |
| 5 | Optimize caching | Laravel’s cache drivers |
Request object differences).TEMPLATING.md.ctype_* functions, json_* APIs).error_reporting(E_ALL) and xdebug to catch strict typing issues.| Risk | Impact | Mitigation | New Considerations |
|---|---|---|---|
| PHP 8.1 Incompatibility | App crashes on startup | Upgrade PHP or abandon package | Critical for this release |
| Symfony 8.x Conflicts | Broken functionality | Abstract Symfony calls via adapters | Test with symfony/options-resolver |
| Twig extension crashes | 500 errors | Feature flags for extensions | |
| Template caching corruption | Stale views | Warm cache on deploy | |
| Dependency conflicts | App startup failures | Composer `platform |
How can I help you explore Laravel packages today?