PHPackages                             mf1/trailing-slash-bundle - 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. mf1/trailing-slash-bundle

ActiveSymfony-plugin

mf1/trailing-slash-bundle
=========================

Mf1TrailingSlashBundle

1183PHP

Since Nov 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/qooplmao/trailing-slash-bundle)[ Packagist](https://packagist.org/packages/mf1/trailing-slash-bundle)[ RSS](/packages/mf1-trailing-slash-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Mf1TrailingSlashBundle
======================

[](#mf1trailingslashbundle)

This bundle enables you to get a big of consistency when it comes to trailing slashes in your Symfony routes.

This idea originally came about when creating an API and having to deal with Symfony routing requirements of having to have, at least, a `/` rather than an empty path. Symfony, very helpfully, handles redirects between routes with trailing slashes to those without (or the other way around.. I forget which). As API routes are usually exposed to a user I reasoned that there should be both uniformity (either all with or without trailing slashes) along with as few redirects as possible.

For example

```
# app/config/routing.yml
routes:
    prefix: /api/
    resource: @AppBundle/Resources/config/routing.yml

# src/AppBundle/Resources/config/routing/yml
routes_1:
    path: /
    ...

routes_2:
    path: /nested
    ...
```

Would become..

```
$ bin/console debug:router

 ---------- -------- -------- ------ -----------------------------------
  Name       Method   Scheme   Host   Path
 ---------- -------- -------- ------ -----------------------------------
  routes_1   ANY      ANY      ANY    /api/
  routes_2   ANY      ANY      ANY    /api/nested
```

In an ideal world they would be `/api` and `/api/nested` (or `/api/` and `/api/nested/`... your choice).

So..

Installation
------------

[](#installation)

1. Download Mf1TrailingSlashBundle using composer
2. Enable the bundle

### Step 1. Download Mf1TrailingSlashBundle using composer

[](#step-1-download-mf1trailingslashbundle-using-composer)

Require the bundle using the command line

```
$ composer require mf1/trailing-slash-bundle

```

### Step 2. Enable the bundle

[](#step-2-enable-the-bundle)

```
