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

ActiveProject

slavikme/slim-api-skeleton
==========================

A skeleton project based on Slim Framework 2. Start developing API applications instantly.

0.9.1(10y ago)258MITPHPPHP &gt;=5.5.0

Since Aug 9Pushed 7y ago5 watchersCompare

[ Source](https://github.com/slavikme/slim-api-skeleton)[ Packagist](https://packagist.org/packages/slavikme/slim-api-skeleton)[ RSS](/packages/slavikme-slim-api-skeleton/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (3)Used By (0)

[![Open Issues](https://camo.githubusercontent.com/47199f60086ff4d253185bdc44dc1b7bb166d860bb90edd76f24db65fae5797e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736c6176696b6d652f736c696d2d6170692d736b656c65746f6e2e737667)](https://github.com/slavikme/slim-api-skeleton/issues) [![Stars on GitHub](https://camo.githubusercontent.com/8234fe2038ba066661709c066305c71298900006649941aea0aff528e63a720a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f736c6176696b6d652f736c696d2d6170692d736b656c65746f6e2e737667)](https://github.com/slavikme/slim-api-skeleton/stargazers) [![Forks on GitHub](https://camo.githubusercontent.com/2fc555c77f3cfca72333c8112b131e458a7a866c68db4de3506733cfee447285/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f736c6176696b6d652f736c696d2d6170692d736b656c65746f6e2e737667)](https://github.com/slavikme/slim-api-skeleton/network) [![Sponsor by PayPal](https://camo.githubusercontent.com/06d34fd092546d743ccd42b0f8c83a7719cb6bc5fecddc82aa1d28246b8fb9ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73706f6e736f722d50617950616c2d626c75652e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4W82MPH26GN6L&source=url) [![GitHub license](https://camo.githubusercontent.com/13cfd267b6f8893fb1a4b0f5def16a2777bb3430abe451f1fab5988798f0378f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736c6176696b6d652f736c696d2d6170692d736b656c65746f6e2e737667)](https://github.com/slavikme/slim-api-skeleton/blob/master/LICENSE)

Slim API Skeleton
=================

[](#slim-api-skeleton)

A skeleton project based on Slim Framework 2, which targets for developers to start an API application instantly.

NOTE: This is an alpha version and it is currently in a developmnet process
---------------------------------------------------------------------------

[](#note-this-is-an-alpha-version-and-it-is-currently-in-a-developmnet-process)

Contributions are welcomed!

Implemented
-----------

[](#implemented)

- Composer create-project functionality
- Application configuration in a single file
- Relational Database support
- Authentication support based on API token with the following user information sources
    - From relational database
- Customizable API token expiration time with predefined default and maximum values
- Routing settings in a single file
    - Define an HTTP Method or array of methods
    - Route with parameters
    - Controller class and class method
    - Define conditions to parameters
- Controller classes support

TODO
----

[](#todo)

1. Add authentication support based on API key with the following user information sources
2. From Configuration File
3. From Big Data/NoSQL records
4. Add authorization support
5. Add logging
6. Add Caching mechanism
7. Auto-doc generator

Recommendations
---------------

[](#recommendations)

It is strongly recommended to install this framework on UNIX-based operating systems (Linux or Macintosh), as it is much easier and much faster to make everything work smoothly.
Of course you can make it work on Windows, but I would recommend to save your valuable time and prevent unnecessary headache.
In this documentation, I will explain how to make it work on UNIX-based system and not on Windows. If you still want to install it on Windows, I'm sorry, but you'll have to figure it out by yourself.
Note: You can always [run a VM (Virtual Machine) with a Linux](http://www.howtogeek.com/196060/beginner-geek-how-to-create-and-use-virtual-machines/), using a [VirtualBox](https://www.virtualbox.org/) or any [other virtual machine](http://lifehacker.com/5714966/five-best-virtual-machine-applications) to install a Linux OS. And then proceed with this documentation on your newly installed Linux on your VM.

Requirements
------------

[](#requirements)

- **Apache 2.x** (or if you prefer Nginx, you will have to make sure that the Authorization header is passed in to your PHP application as described in the `public/.htaccess` file. Also, you should rewrite everything to point to the `public/app.php` file)
- **PHP 5.6+**
- **MySQL 5.5+**
- **Composer 0.9+** ([installation instructions](https://getcomposer.org/doc/00-intro.md))

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

[](#installation)

**INCOMPLETE!**

1. Open a command line interface.
2. Navigate to the path where you want to create the project directory.
3. Run the following command:

    ```
    composer create-project slavikme/slim-api-skeleton

    ```
4. Follow the instructions.
5. Create a Virtual Host with the hostname `slimapi.local` and point the base directory to the `public` directory.

Usage
-----

[](#usage)

**INCOMPLETE!**

Just call any path defined in the `routes.yml`, with the token received from the [Authentication](#authentication) process below, in the `Authorization` request header along with the phrase `Bearer`. For example:

```
GET / HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lIjoxNDM5MDQzMDkxLCJleHB0aW1lIjogMTQzOTA0NDI5MSwidXNlciI6eyJpZCI6IjEiLCJ1c2VybmFtZSI6ImVhc3Rlci1lZ2ciLCJyb2xlIjoiQURNSU4iLCJuYW1lIjoiQ29uZ3JhdHMsIE5vdyBZb3UgVW5kZXJzdGFuZCBUaGUgSldUIFByb3RvY29sIiwiZW1haWwiOiJnb29kQGpvYi5jb20iLCJzdGF0dXMiOiIxIiwibGFzdGxvZ2luX3RpbWUiOiIyMDE1LTA4LTA2IDE3OjEwOjA0In19.4YHynX_j2mhXLWGgLTHTf6IgY5HwHBIzl8mUqQa8vUw
Host: api.slim.local
Connection: close

```

### Authentication

[](#authentication)

The authentication method implemented in this framework is [JWT (JSON Web Tokens)](http://jwt.io/).
A special authentication route has been implemented and is ready to use out of the box.

#### Request

[](#request)

Use the route `/auth` with the method `POST` to authenticate by sending mandatory credentials `username` and `password`, and optional credential `remember_minutes` in the body of the request wrapped in form or JSON formats (both are supported equally).
The request body should be sent as follows:

##### JSON Format

[](#json-format)

```
{
    "username": "john",
    "password": "Snow123",
    "expiration": "45 minutes"
}

```

> Note: JSON format requests must be sent along with the `Content-Type: application/json` header property in the request headers in order to make it work.

##### Form Format

[](#form-format)

```
username=john&password=Snow123&expiration=45%20minutes

```

##### Request Parameters

[](#request-parameters)

- **`username`** - The username from the `tbl_user` table (See the [Database - User Table](#user-table) section).
- **`password`** - The username from the `tbl_user` table (See the [Database - User Table](#user-table) section).
- **`expiration`** - A date/time string when the token expires (The same value as the PHP [strtotime](http://php.net/manual/function.strtotime.php)() function accepts in its first argument). This parameter is optional and may not be sent. If this parameter will not be sent, the default value will be used as defined within the `auth.lifetime` property located in `config/parameters.yml` file.

#### Response

[](#response)

The response depending on the request. If the authentication route has been requested without different, incorrect or invalid parameters, or without any username-password match in the `tbl_user` table, or user's status is equal or lower than 0, the response will be always 401 as an HTTP status code with the following JSON data in the body:

```
{
    "error": true,
    "msg": "Unauthorized access",
    "status": 401
}

```

Otherwise, the authentication should succeed with the response status code 200 and response body similar to the following:

```
{
    "error": false,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lIjoxNDM5MDQzMDkxLCJleHB0aW1lIjogMTQzOTA0NDI5MSwidXNlciI6eyJpZCI6IjEiLCJ1c2VybmFtZSI6ImVhc3Rlci1lZ2ciLCJyb2xlIjoiQURNSU4iLCJuYW1lIjoiQ29uZ3JhdHMsIE5vdyBZb3UgVW5kZXJzdGFuZCBUaGUgSldUIFByb3RvY29sIiwiZW1haWwiOiJnb29kQGpvYi5jb20iLCJzdGF0dXMiOiIxIiwibGFzdGxvZ2luX3RpbWUiOiIyMDE1LTA4LTA2IDE3OjEwOjA0In19.4YHynX_j2mhXLWGgLTHTf6IgY5HwHBIzl8mUqQa8vUw",
    "status": 200
}

```

##### Response Referense

[](#response-referense)

- **`status`** - The status of the response, mostly is the response status code. Always included in the response.
- **`error`** - Indicates whether an error has occurred for any possible reason. This will return `true` on error along with `msg` parameter, otherwise will return `false`. Always included in the response.
- **`msg`** - A string that explains why the error has been occurred. Should always be included if `error` is `true`.
- **`token`** - A valid JWT authentication token, used for authenticated requests in this API (Usage explained in the [Request - Authenticated Usage](#authenticated-usage) section).

#### Authenticated Usage

[](#authenticated-usage)

**TODO:** Complete this section

Database
--------

[](#database)

### User Table

[](#user-table)

The following code used to create a new user table manually.

```
CREATE TABLE `tbl_user` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(50) NOT NULL,
    `password` varchar(255) NOT NULL,
    `role` varchar(50) NOT NULL,
    `name` varchar(255) DEFAULT NULL,
    `email` varchar(255) DEFAULT NULL,
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    `status` tinyint(4) NOT NULL DEFAULT '1',
    `lastlogin_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `username_UNIQUE` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

Every ~0 days

Total

2

Last Release

3926d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aba7a835d0d344b229536bdd1a3a38111b4e65b9d7cfc788eea673360bce6d89?d=identicon)[slavikme](/maintainers/slavikme)

---

Top Contributors

[![slavikme](https://avatars.githubusercontent.com/u/3010215?v=4)](https://github.com/slavikme "slavikme (18 commits)")

### Embed Badge

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

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

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M55](/packages/roave-backward-compatibility-check)[internachi/modular

Modularize your Laravel apps

1.1k662.4k8](/packages/internachi-modular)[wsdltophp/packagegenerator

Generate hierarchical PHP classes based on a WSDL

4351.9M19](/packages/wsdltophp-packagegenerator)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[october/rain

October Rain Library

1601.7M62](/packages/october-rain)

PHPackages © 2026

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