PHPackages                             marcin-jozwikowski/easy-admin-pretty-urls - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. marcin-jozwikowski/easy-admin-pretty-urls

AbandonedArchivedSymfony-bundle

marcin-jozwikowski/easy-admin-pretty-urls
=========================================

Semi-automatic URL generator for pretty REST-like URLs in EasyAdmin

v2.9.3(1y ago)2917.0k↑22.2%7MITPHPPHP &gt;=8.0

Since Dec 24Pushed 1y ago2 watchersCompare

[ Source](https://github.com/marcin-jozwikowski/easy-admin-pretty-urls)[ Packagist](https://packagist.org/packages/marcin-jozwikowski/easy-admin-pretty-urls)[ RSS](/packages/marcin-jozwikowski-easy-admin-pretty-urls/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (26)Used By (0)

EasyAdmin Pretty URLs
=====================

[](#easyadmin-pretty-urls)

### Symfony Bundle that introduces customizable routes to EasyAdmin

[](#symfony-bundle-that-introduces-customizable-routes-to-easyadmin)

Example
-------

[](#example)

Turn

```
  http://ea-demo.loc/en/easyadmin?crudAction=index&crudControllerFqcn=App%5CController%5CEasyAdmin%5CPostCrudController

```

into

```
  http://ea-demo.loc/en/post_crud/index

```

---

Instalation
-----------

[](#instalation)

1. Install the bundle by running

    ```
    composer require marcin-jozwikowski/easy-admin-pretty-urls
    ```
2. Enable the bundle by adding it to your `config/bundles.php` if not enabled automatically

    ```
    return [
      // ...
      MarcinJozwikowski\EasyAdminPrettyUrls\EasyAdminPrettyUrlsBundle::class => ['all' => true],
    ];
    ```
3. Add a routes set pointing to a directory containing your Controllers

    ```
    pretty_routes_name:
     resource: 'src/Controller'
     type: 'pretty_routes'
    ```

    The `resource` is a directory path relative to your projects root directory. Type must always equal to `pretty_routes`. See [*Fine-tuning* / *Define routes manually*](#Fine-tuning) section to learn how this step can be ommitted.

    Other routing structures can be utilized as well, for example:

    ```
     pretty_routes:
       resource: 'src/Controller'
       type: 'pretty_routes'
       prefix: /{_locale}
       requirements:
         _locale: '%app_locales%'
       defaults:
         _locale: '%locale%'
    ```
4. Make your main DashboardController extend `\MarcinJozwikowski\EasyAdminPrettyUrls\Controller\PrettyDashboardController` or manually override the a default template like so:

    ```
    public function configureCrud(): Crud
     {
         return parent::configureCrud()
             ->overrideTemplate('layout', '@EasyAdminPrettyUrls/layout.html.twig')
             ->overrideTemplate('crud/field/association', '@EasyAdminPrettyUrls/crud/field/association.html.twig');
     }
    ```

Configuration
-------------

[](#configuration)

The following parameters are in use:

ParameterDefault valueDescription`route_prefix``"pretty"`First part of route name`default_dashboard``"App\Controller\EasyAdmin\DashboardController::index"`Default controller action to invoke if not specified in attributes`default_actions``["index", "new", "detail", "edit", "delete", "batchDelete", "renderFilters", "autocomplete"]`Default set of actions to build routes against`include_menu_index``false`Should menu index be included in path`drop_entity_fqcn``false`Should `entityFqcn` be removed from the URLsTo change the default values set the parameter in your `services.yaml`

```
  parameters:
    easy_admin_pretty_urls.: ''
```

Or create a `config/packages/easyadmin_pretty_urls.yaml` file with

```
  easy_admin_pretty_urls:
    : ''
```

Twig
----

[](#twig)

There are one function, and one filter being registered by a Twig extension in this bundle:

- `pretty_urls_include_menu_index()` Function returns the `include_menu_index` value from Configuration
- `|pretty_urls_remove_actions` Filter removed the unnecessary query elements from the URL string

Fine-tuning
-----------

[](#fine-tuning)

- ### Define custom URL path

    [](#define-custom-url-path)

    By default, the URL is created as `/`.

    To change that behavior specify `path` value in `PrettyRoutesController` attribute for the whole controller, and/or in `PrettyRoutesAction` attribute for the specific action.

    The following configuration will result in the action URL of `special/list` instead of the default `any_fancy/index`.

    ```
    #[PrettyRoutesController(path: 'special')]
    class AnyFancyController {

      #[PrettyRoutesAction(path: 'list')]
      public function index() {
        // ....
      }
    }
    ```
- ### Putting entityID in the path

    [](#putting-entityid-in-the-path)

    With a custom path defined in `#PrettyRoutesAction` attribute, it is possible to include the entityID in the path.

    To achieve it, simple add `{entityId?0}` to the `path` argument i.e.

    ```
    #[PrettyRoutesAction(path: 'modify/{entityId?0}')]
    public function edit(AdminContext $context)
    {
      return parent::edit($context);
    }
    ```

    Due to the way form actions are generated by EasyAdmin it is necessary to specify a default value for the parameter in the path.

    It does not have to be `0` but keep in mind that setting it to an existing ID will make the application unusable.
- ### Select actions to create routes for

    [](#select-actions-to-create-routes-for)

    By default, pretty routes are generated for `index`, `new`, `detail`, `edit`, `delete`, `batchDelete`, `renderFilters`, and `autocomplete` actions.

    To change them globally set a proper [*configuration*](#Configuration) value. For a single-controller change add a `PrettyRoutesController` attribute to the controller and name the actions you want to have pretty routes for, in `actions` parameter.

    ```
    #[PrettyRoutesController(actions: ['index', 'foo', 'bar'])]
    class AnyFancyController {
      // ...
    }

    /**
    * You can also (optionally) specify your own dashboard controller if you're using more than one in your project.
    * This will avoid to have an incorrect sidebar/user menu by addressing the request to the right dashboard controller
    */
    #[PrettyRoutesController(actions: ['index', 'foo', 'bar'], dasboard: YourCrudController::class . '::yourCrudAction')]
    class AnyFancyController {
      // ...
    }
    ```

    You can also just add your custom actions to the default list by specifying `customActions` in `PrettyRoutesController` attribute.

    ```
    #[PrettyRoutesController(customActions: ['foo', 'bar'])]
    class AnyFancyController {
    ...
    ```
- ### Define routes manually

    [](#define-routes-manually)

    Instead of defining a `pretty_routes` routes to automatically parse all classes in a directory you can create routes that will replace your default EasyAdmin CRUD actions.

    ```
    pretty_foobar_index:
      path: /foobar-url
      controller: \App\Controller\EasyAdmin\DashboardController::index
      defaults:
          crudControllerFqcn: \App\Controller\FoobarCrudController
          crudAction: index
    ```

    - `controller` value must point to your projects DashboardController
    - `defaults` `crudControllerFqcn` and `crudAction` must point to your target CRUD controller and its action.
    - `path` can be anything of your choosing
    - Route name must match the pattern `__` with
        - `` equal to `crudAction` value from the defaults
        - `` being the target controller class name (not FQCN - just the last part) stripped of `Controller`, written in *snake\_case*
        - `` is set to `pretty` by default. See Configuration to ways to change it.
    - When routes are defined manually the *Installation step 3* is not required.

    You can generate a YAML routes configuration for existing controllers for further manual modifications by running

    ```
      bin/console pretty-routes:dump
    ```

Troubleshooting
---------------

[](#troubleshooting)

- ### Routes not working

    [](#routes-not-working)

    If your routes are still not generated despite being added, check your logs for `'Pretty route not found'` with `debug` level. Those will list all the EasyAdmin routes that did not have their pretty counterparts.

    Most probably, there's some naming mismatch.
- ### Checking the Resource parsing results

    [](#checking-the-resource-parsing-results)

    To see what is the outcome of parsing a `pretty_routes` Resource run the following command:

    ```
      bin/console pretty-routes:debug
    ```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~29 days

Recently: every ~23 days

Total

24

Last Release

559d ago

Major Versions

v1.2.0 → v2.0.02023-01-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5331237?v=4)[Marcin Jóźwikowski](/maintainers/marcin-jozwikowski)[@marcin-jozwikowski](https://github.com/marcin-jozwikowski)

---

Top Contributors

[![marcin-jozwikowski](https://avatars.githubusercontent.com/u/5331237?v=4)](https://github.com/marcin-jozwikowski "marcin-jozwikowski (52 commits)")[![andrew-demb](https://avatars.githubusercontent.com/u/12499813?v=4)](https://github.com/andrew-demb "andrew-demb (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")[![dunglas](https://avatars.githubusercontent.com/u/57224?v=4)](https://github.com/dunglas "dunglas (1 commits)")[![Geolim4](https://avatars.githubusercontent.com/u/1332071?v=4)](https://github.com/Geolim4 "Geolim4 (1 commits)")[![tviertel](https://avatars.githubusercontent.com/u/64088399?v=4)](https://github.com/tviertel "tviertel (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marcin-jozwikowski-easy-admin-pretty-urls/health.svg)

```
[![Health](https://phpackages.com/badges/marcin-jozwikowski-easy-admin-pretty-urls/health.svg)](https://phpackages.com/packages/marcin-jozwikowski-easy-admin-pretty-urls)
```

###  Alternatives

[easycorp/easyadmin-demo

EasyAdmin Demo Application

145.7k](/packages/easycorp-easyadmin-demo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
