Skip to content

Add 4.39 recipe for sonata-project/admin-bundle with PHP routing - #1993

Merged
symfony-recipes-bot merged 1 commit into
symfony:mainfrom
virtualize:fix/sonata-admin-bundle-php-routing-4.39
Jun 3, 2026
Merged

Add 4.39 recipe for sonata-project/admin-bundle with PHP routing#1993
symfony-recipes-bot merged 1 commit into
symfony:mainfrom
virtualize:fix/sonata-admin-bundle-php-routing-4.39

Conversation

@virtualize

Copy link
Copy Markdown
Contributor
Q A
License MIT
Packagist https://packagist.org/packages/sonata-project/admin-bundle

Problem

sonata_admin.xml routing is broken in Symfony 8.0, which removed XmlFileLoader support for routing (it was deprecated in 7.4). This causes:

Cannot load resource "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"

See: sonata-project/SonataAdminBundle#8374

Why a new recipe version instead of editing 4.0

The PHP routing file sonata_admin.php was introduced in SonataAdminBundle 4.39.0. Modifying the 4.0 recipe to reference it would break installations running older versions (as noted in the review on PR #1989).

Solution

Add a new 4.39 recipe version that references sonata_admin.php with type: php, leaving the 4.0 recipe untouched for older installs.

This supersedes PR #1989 which addressed the same issue but modified the 4.0 recipe directly.

Symfony 8.0 removed XmlFileLoader support for routing (deprecated in 7.4).
The PHP routing file sonata_admin.php was introduced in SonataAdminBundle 4.39,
so a new recipe version is required rather than modifying the existing 4.0 recipe.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@symfony-recipes-bot
symfony-recipes-bot enabled auto-merge (squash) June 3, 2026 13:59
@symfony-recipes-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1993/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1993/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'sonata-project/admin-bundle:^4.39'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

sonata-project/admin-bundle

3.31 vs 3.64
diff --git a/sonata-project/admin-bundle/3.31/config/packages/sonata_admin.yaml b/sonata-project/admin-bundle/3.64/config/packages/sonata_admin.yaml
index 28f4f348..7e3ca920 100644
--- a/sonata-project/admin-bundle/3.31/config/packages/sonata_admin.yaml
+++ b/sonata-project/admin-bundle/3.64/config/packages/sonata_admin.yaml
@@ -3,6 +3,8 @@ sonata_admin:
     dashboard:
         blocks:
             - { type: sonata.admin.block.admin_list, position: left }
+    options:
+        legacy_twig_text_extension: false
 
 sonata_block:
     blocks:
3.64 vs 4.0
diff --git a/sonata-project/admin-bundle/3.64/config/packages/sonata_admin.yaml b/sonata-project/admin-bundle/4.0/config/packages/sonata_admin.yaml
index 7e3ca920..28f4f348 100644
--- a/sonata-project/admin-bundle/3.64/config/packages/sonata_admin.yaml
+++ b/sonata-project/admin-bundle/4.0/config/packages/sonata_admin.yaml
@@ -3,8 +3,6 @@ sonata_admin:
     dashboard:
         blocks:
             - { type: sonata.admin.block.admin_list, position: left }
-    options:
-        legacy_twig_text_extension: false
 
 sonata_block:
     blocks:
4.0 vs 4.39
diff --git a/sonata-project/admin-bundle/4.0/config/routes/sonata_admin.yaml b/sonata-project/admin-bundle/4.39/config/routes/sonata_admin.yaml
index c009e3bf..8bf4a649 100644
--- a/sonata-project/admin-bundle/4.0/config/routes/sonata_admin.yaml
+++ b/sonata-project/admin-bundle/4.39/config/routes/sonata_admin.yaml
@@ -1,5 +1,6 @@
 admin_area:
-    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
+    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.php"
+    type: php
     prefix: /admin
 
 _sonata_admin:

@@ -0,0 +1,9 @@
admin_area:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.php"
type: php

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think type is necessary for it to work.

@symfony-recipes-bot
symfony-recipes-bot merged commit 06f445b into symfony:main Jun 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants