PHPackages                             yoganandgopalan/slim-skeleton - 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. yoganandgopalan/slim-skeleton

ActiveLibrary[Framework](/categories/framework)

yoganandgopalan/slim-skeleton
=============================

Boilerplate for building a REST API with Slim PHP micro-framework With Limit, Filtering, Full text search, Sorting

v1.0.0(7y ago)4281MITPHPPHP ^7.0

Since May 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yoganandgopalan/slim-skeleton)[ Packagist](https://packagist.org/packages/yoganandgopalan/slim-skeleton)[ Docs](https://github.com/yoganandgopalan/slim-skeleton)[ RSS](/packages/yoganandgopalan-slim-skeleton/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (12)Versions (2)Used By (0)

Slim REST base - A Slim 3 skeleton
==================================

[](#slim-rest-base---a-slim-3-skeleton)

This is an app skeleton for the Slim PHP Micro-Framework to get started quickly building a REST API, with CRUD, Sorting, Pagination &amp;filtering

Features
--------

[](#features)

- [Eloquent ORM](https://github.com/illuminate/database)
- Authentication ([Sentinel](https://github.com/cartalyst/sentinel))
- Validation ([Respect](https://github.com/Respect/Validation) + [Slim Validation](https://github.com/awurth/slim-validation))
- Logs ([Monolog](https://github.com/Seldaek/monolog))
- Console commands for updating the database schema and creating users
- A RESTful router

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

[](#installation)

```
$ composer create-project -s dev yoganandgopalan/slim-skeleton [app-name]
```

### Download vendor packages

[](#download-vendor-packages)

```
$ composer update
```

Features
--------

[](#features-1)

### Create database tables

[](#create-database-tables)

```
$ php bin/console db
```

### Create users

[](#create-users)

```
$ php bin/console user:create
```

Use `--admin` option to set the user as admin

### Dump routes

[](#dump-routes)

Execute the following command at the project root to print all routes in your terminal

```
$ php bin/console routes
```

Use --markdown or -m option to display routes in markdown format

```
$ php bin/console routes -m > API.md
```

If you're using [Oh My Zsh](https://github.com/robbyrussell/oh-my-zsh), you can install the symfony2 plugin, which provides an alias and autocompletion:

```
# Without Symfony2 plugin
$ php bin/console db

# With Symfony2 plugin
$ sf db
```

Note
----

[](#note)

You might want to replace the authentication part with a real OAuth implementation

Sort, Filter, Limits
--------------------

[](#sort-filter-limits)

#### Custom identification columns

[](#custom-identification-columns)

If you pass an array as the second parameter to `parseSingle`, there now have to be column/value pairs. This allows us to pass multiple conditions like:

```
SortFilter::parseSingle($request, $books, array('id_origin' => 'Random Bookstore Ltd', 'id' => 1337));
```

### URL parsing

[](#url-parsing)

Url parsing currently supports:

- Limit the fields
- Filtering
- Full text search
- Sorting
- Define limit and offset

There are two kind of api resources supported, a single object and a collection of objects.

#### Single object

[](#single-object)

If you handle a GET request on a resource representing a single object like for example `/api/books/1`, use the `parseSingle` method.

**parseSingle($request, $queryBuilder, $identification, \[$queryParams\]):**

- **$request**: Request from controller
- **$queryBuilder**: Query builder object, Eloquent model or Eloquent relation
- **$identification**: An integer used in the `id` column or an array column/value pair(s) (`array('isbn' => '1234')`) used as a unique identifier of the object.
- **$queryParams**: An array containing the query parameters. If not defined, the original GET parameters are used.

```
SortFilter::parseSingle($request, $book, 1);
```

#### Collection of objects

[](#collection-of-objects)

If you handle a GET request on a resource representing multiple objects like for example `/api/books`, use the `parseMultiple` method.

**parseMultiple($request, $queryBuilder, $fullTextSearchColumns, \[$queryParams\]):**

- **$request**: Request from controller
- **$queryBuilder**: Query builder object, Eloquent model or Eloquent relation
- **$fullTextSearchColumns**: An array which defines the columns used for full text search.
- **$queryParams**: An array containing the query parameters. If not defined, the original GET parameters are used.

```
SortFilter::parseMultiple($request, $book, array('title', 'isbn', 'description'));
```

#### Result

[](#result)

Both `parseSingle` and `parseMultiple` return a `Result` object with the following methods available:

**getBuilder():**Returns the original `$queryBuilder` with all the functions applied to it.

**getResult():**Returns the result object returned by Laravel's `get()` or `first()` functions.

**getResultOrFail():**Returns the result object returned by Laravel's `get()` function if you expect multiple objects or `firstOrFail()` if you expect a single object.

**getResponse($resultOrFail = false):**Returns a Laravel `Response` object including body, headers and HTTP status code. If `$resultOrFail` is true, the `getResultOrFail()` method will be used internally instead of `getResult()`.

**cleanup($cleanup):**If true, the resulting array will get cleaned up from unintentionally added relations. Such relations can get automatically added if they are accessed as properties in model accessors. The global default for the cleanup can be defined using the config option `cleanup_relations` which defaults to `false`.

```
SortFilter::parseSingle($books, 42)->cleanup(true)->getResponse();
```

#### Filtering

[](#filtering)

Every query parameter, except the predefined functions `_fields`, `_sort`, `_limit`, `_offset` and `_q`, is interpreted as a filter. Be sure to remove additional parameters not meant for filtering before passing them to `parseMultiple`.

```
/api/books?title=The Lord of the Rings

```

All the filters are combined with an `AND` operator.

```
/api/books?title-lk=The Lord*&created_at-min=2014-03-14 12:55:02

```

The above example would result in the following SQL where:

```
WHERE `title` LIKE "The Lord%" AND `created_at` >= "2014-03-14 12:55:02"
```

Its also possible to use multiple values for one filter. Multiple values are separated by a pipe `|`. Multiple values are combined with `OR` except when there is a `-not` suffix, then they are combined with `AND`. For example all the books with the id 5 or 6:

```
/api/books?id=5|6

```

Or all the books except the ones with id 5 or 6:

```
/api/books?id-not=5|6

```

The same could be achieved using the `-in` suffix:

```
/api/books?id-in=5,6

```

Respectively the `not-in` suffix:

```
/api/books?id-not-in=5,6

```

##### Suffixes

[](#suffixes)

SuffixOperatorMeaning-lkLIKESame as the SQL `LIKE` operator-not-lkNOT LIKESame as the SQL `NOT LIKE` operator-inINSame as the SQL `IN` operator-not-inNOT INSame as the SQL `NOT IN` operator-min&gt;=Greater than or equal to-max&lt;=Smaller than or equal to-st&lt;Smaller than-gt&gt;Greater than-not!=Not equal to#### Sorting

[](#sorting)

Two ways of sorting, ascending and descending. Every column which should be sorted descending always starts with a `-`.

```
/api/books?_sort=-title,created_at

```

#### Fulltext search

[](#fulltext-search)

Two implementations of full text search are supported. You can choose which one to use by changing the `fulltext` option in the config file to either `default` or `native`.

***Note:*** When using an empty `_q` param the search will always return an empty result.

**Limited custom implementation (default)**

A given text is split into keywords which then are searched in the database. Whenever one of the keyword exists, the corresponding row is included in the result set.

```
/api/books?_q=The Lord of the Rings

```

The above example returns every row that contains one of the keywords `The`, `Lord`, `of`, `the`, `Rings` in one of its columns. The columns to consider in full text search are passed to `parseMultiple`.

**Native MySQL implementation**

If your MySQL version supports fulltext search for the engine you use you can use this advanced search in the api handler.
Just change the `fulltext` config option to `native` and make sure that there is a proper fulltext index on the columns you pass to `parseMultiple`.

Each result will also contain a `_score` column which allows you to sort the results according to how well they match with the search terms. E.g.

```
/api/books?_q=The Lord of the Rings&_sort=-_score

```

You can adjust the name of this column by modifying the `fulltext_score_column` setting in the config file.

#### Limit the result set

[](#limit-the-result-set)

To define the maximum amount of datasets in the result, use `_limit`.

```
/api/books?_limit=50

```

To define the offset of the datasets in the result, use `_offset`.

```
/api/books?_offset=20&_limit=50

```

Be aware that in order to use `offset` you always have to specify a `limit` too. MySQL throws an error for offset definition without a limit.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2905d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49b296ca1ad4c706b50427e713183ae9594e498fefb9c2710b67fa900aadfc78?d=identicon)[yoganand\_19\_19](/maintainers/yoganand_19_19)

---

Top Contributors

[![yoganandgopalan](https://avatars.githubusercontent.com/u/11992704?v=4)](https://github.com/yoganandgopalan "yoganandgopalan (6 commits)")

---

Tags

microservicesslim-frameworkapiframeworkrestslimeloquentboilerplateSkeletonfilteringsortingfull text searchLimit the fieldsDefine limit and offset

### Embed Badge

![Health badge](/badges/yoganandgopalan-slim-skeleton/health.svg)

```
[![Health](https://phpackages.com/badges/yoganandgopalan-slim-skeleton/health.svg)](https://phpackages.com/packages/yoganandgopalan-slim-skeleton)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[gotzmann/comet

Modern PHP framework for building blazing fast REST APIs and microservices

68816.2k1](/packages/gotzmann-comet)[patricksavalle/slim-rest-api

Production-grade REST-API App-class for PHP SLIM, in production on https://zaplog.pro (https://api.zaplog.pro/v1)

101.4k](/packages/patricksavalle-slim-rest-api)

PHPackages © 2026

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