PHPackages                             mangopeaches/slim-route-groups - 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. [Framework](/categories/framework)
4. /
5. mangopeaches/slim-route-groups

ActiveLibrary[Framework](/categories/framework)

mangopeaches/slim-route-groups
==============================

Wrapper for slim router which simplifies route definitions and organization.

v1.0.1(7y ago)029MITPHPPHP &gt;=5.6

Since May 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mangopeaches/SlimRouteGroups)[ Packagist](https://packagist.org/packages/mangopeaches/slim-route-groups)[ RSS](/packages/mangopeaches-slim-route-groups/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

SlimRouteGroups
===============

[](#slimroutegroups)

[![Build Status](https://camo.githubusercontent.com/7ed6fd7f3b595e16ac80a40e0c676778c3dd3eedcb9cca0a6facf5fd4fc2729d/68747470733a2f2f7472617669732d63692e6f72672f6d616e676f706561636865732f536c696d526f75746547726f7570732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mangopeaches/SlimRouteGroups)

Wrapper for slim router which simplifies route definitions and organization.

Demo App
--------

[](#demo-app)

For a usable demo implementation, see [SlimRouteGroupsDemo](https://github.com/mangopeaches/SlimRouteGroupsDemo)

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

[](#installation)

```
composer require mangopeaches/slim-route-groups
```

The Problem
-----------

[](#the-problem)

If your organization is using the Slim Framework for any decent sized API project you likely have a lot of routes.

If you hadn't given it a lot of though you soon end up with a routes file the can look similar to the following.

```
$app->group('/users', function($app) {
    $app->get('', 'Path\To\Users:getAll');
    $app->post('', 'Path\To\Users:create');
});

$app->group('/books', function($app) {
    $app->get('', 'Path\To\Books:getAll');
    $app->post('', 'Path\To\Books:create');
});
```

This is fine up to a point, but when you start developing overlapping sections, adding options routes, or have multiple developers changing routes.php this setup can start to cause some trouble.

The Solution
------------

[](#the-solution)

A little planning goes a long way. The objective of this project is to separate your routes per resource or whatever your ideal of logical groups is to save conflict nightmare and keep your routes isolated and simple.

Let's do the same as above in this new way.

We'd create two separate route files.

UsersRoutes.php

```
