Skip to content

[EasyAdmin] Add pretty admin URL routes #1381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 26, 2025

Conversation

SebLevDev
Copy link
Contributor

Q A
License MIT

This pull request adds a new route configuration for EasyAdmin in the easyadmin.yaml file. The new configuration defines autoload for new pretty URL
The support for pretty admin URLs was introduced in EasyAdmin 4.14.0.

The support for pretty admin URLs was introduced in EasyAdmin 4.14.0.
Copy link

github-actions bot commented Feb 26, 2025

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/flex/pull-1381/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1381/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'easycorp/easyadmin-bundle:^4.14'
  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.

easycorp/easyadmin-bundle

1.17 vs 2.0
diff --git a/easycorp/easyadmin-bundle/1.17/config/routes/easy_admin.yaml b/easycorp/easyadmin-bundle/2.0/config/routes/easy_admin.yaml
index 1014c71..c62135c 100644
--- a/easycorp/easyadmin-bundle/1.17/config/routes/easy_admin.yaml
+++ b/easycorp/easyadmin-bundle/2.0/config/routes/easy_admin.yaml
@@ -1,4 +1,4 @@
 easy_admin_bundle:
-    resource: '@EasyAdminBundle/Controller/AdminController.php'
+    resource: '@EasyAdminBundle/Controller/EasyAdminController.php'
     prefix: /admin
     type: annotation
2.0 vs 3.0
diff --git a/easycorp/easyadmin-bundle/2.0/config/packages/easy_admin.yaml b/easycorp/easyadmin-bundle/2.0/config/packages/easy_admin.yaml
deleted file mode 100644
index 8ad6ecc..0000000
--- a/easycorp/easyadmin-bundle/2.0/config/packages/easy_admin.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-#easy_admin:
-#    entities:
-#        # List the entity class name you want to manage
-#        - App\Entity\Product
-#        - App\Entity\Category
-#        - App\Entity\User
diff --git a/easycorp/easyadmin-bundle/2.0/config/routes/easy_admin.yaml b/easycorp/easyadmin-bundle/2.0/config/routes/easy_admin.yaml
deleted file mode 100644
index c62135c..0000000
--- a/easycorp/easyadmin-bundle/2.0/config/routes/easy_admin.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-easy_admin_bundle:
-    resource: '@EasyAdminBundle/Controller/EasyAdminController.php'
-    prefix: /admin
-    type: annotation
diff --git a/easycorp/easyadmin-bundle/2.0/manifest.json b/easycorp/easyadmin-bundle/3.0/manifest.json
index dd96174..bd6763a 100644
--- a/easycorp/easyadmin-bundle/2.0/manifest.json
+++ b/easycorp/easyadmin-bundle/3.0/manifest.json
@@ -2,8 +2,5 @@
     "bundles": {
         "EasyCorp\\Bundle\\EasyAdminBundle\\EasyAdminBundle": ["all"]
     },
-    "copy-from-recipe": {
-        "config/": "%CONFIG_DIR%/"
-    },
     "aliases": ["admin-gen", "admin-generator", "admin"]
 }
3.0 vs 4.14
diff --git a/easycorp/easyadmin-bundle/4.14/config/routes/easyadmin.yaml b/easycorp/easyadmin-bundle/4.14/config/routes/easyadmin.yaml
new file mode 100644
index 0000000..083ca15
--- /dev/null
+++ b/easycorp/easyadmin-bundle/4.14/config/routes/easyadmin.yaml
@@ -0,0 +1,3 @@
+easyadmin:
+    resource: .
+    type: easyadmin.routes
diff --git a/easycorp/easyadmin-bundle/3.0/manifest.json b/easycorp/easyadmin-bundle/4.14/manifest.json
index bd6763a..e4b7057 100644
--- a/easycorp/easyadmin-bundle/3.0/manifest.json
+++ b/easycorp/easyadmin-bundle/4.14/manifest.json
@@ -1,6 +1,9 @@
 {
     "bundles": {
         "EasyCorp\\Bundle\\EasyAdminBundle\\EasyAdminBundle": ["all"]
+    },    
+    "copy-from-recipe": {
+        "config/": "%CONFIG_DIR%/"
     },
     "aliases": ["admin-gen", "admin-generator", "admin"]
 }

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 26, 2025 08:48
Copy link
Contributor

@Pierstoval Pierstoval left a comment

Choose a reason for hiding this comment

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

The PR lacks the manifest.json file, you can add it by copy/pasting the ones from previous versions 👍

auto-merge was automatically disabled February 26, 2025 08:56

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 26, 2025 08:56
auto-merge was automatically disabled February 26, 2025 09:01

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 26, 2025 09:02
auto-merge was automatically disabled February 26, 2025 09:03

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) February 26, 2025 09:04
@SebLevDev
Copy link
Contributor Author

I don't see how to fix the error in the CI

@fabpot
Copy link
Member

fabpot commented Feb 26, 2025

@javiereguiluz

@javiereguiluz
Copy link
Member

I'm not sure to make this change in 4.x version. I was thinking about making it in the upcoming 5.x version.

I've been working hard during these past weeks to have 5.x version ready soon.

@SebLevDev
Copy link
Contributor Author

SebLevDev commented Feb 26, 2025

I'm not sure to make this change in 4.x version. I was thinking about making it in the upcoming 5.x version.

I've been working hard during these past weeks to have 5.x version ready soon.

Currently, version 4.24 does not work by default.

symfony new myProject
cd myProject
composer req admin
php bin/console make:admin:dashboard

The /admin URL returns a 404 Not Found.

php bin/console debug:router does not return any EasyAdmin routes.

Dashboard is by default generated with pretty url but the route is not autoload
#[AdminDashboard(routePath: '/admin', routeName: 'admin')]

@Pierstoval
Copy link
Contributor

Pierstoval commented Feb 26, 2025

@javiereguiluz Without this change, creating a new project using EA 4 will not work because maker and docs say that one must use the AdminDashboard attribute, which uses pretty urls, and isn't available unless this route config is set.

The solution is either to change the docs for 4.x, or to change the recipe for the version in which the annotation was introduced.

For DX, and to ease migration to 5.x, I think it's better to update the recipe

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

OK, you are right 🙏 Let's merge this for 4.x branch too. Thanks!

@symfony-recipes-bot symfony-recipes-bot merged commit 115dcee into symfony:main Feb 26, 2025
1 of 2 checks passed
@SebLevDev SebLevDev deleted the easyadmin-pretty-url branch February 26, 2025 10:30
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.

5 participants