PHPackages                             samuelgfeller/slim-api-starter - 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. [API Development](/categories/api)
4. /
5. samuelgfeller/slim-api-starter

ActiveProject[API Development](/categories/api)

samuelgfeller/slim-api-starter
==============================

API starter template using Slim micro-framework

4.0.0(1y ago)4381MITPHPPHP ^8.2

Since Apr 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/samuelgfeller/slim-api-starter)[ Packagist](https://packagist.org/packages/samuelgfeller/slim-api-starter)[ Fund](https://ko-fi.com/samuelgfeller)[ RSS](/packages/samuelgfeller-slim-api-starter/feed)WikiDiscussions master Synced 1mo ago

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

Slim [![API](https://camo.githubusercontent.com/f5e4b2a286eeb933cc7ff7573a66aa556a166d4cb9e08db5d964f4071ce703a9/68747470733a2f2f692e696d6775722e636f6d2f597a44595130562e706e67)](https://camo.githubusercontent.com/f5e4b2a286eeb933cc7ff7573a66aa556a166d4cb9e08db5d964f4071ce703a9/68747470733a2f2f692e696d6775722e636f6d2f597a44595130562e706e67) starter
=============================================================================================================================================================================================================================================================================================================================================================

[](#slim--starter)

[![Documentation](https://camo.githubusercontent.com/39e91fe0582e922ff24973a8251f6fa88bca571aa697843752e448749a8a193e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63756d656e746174696f6e2d626c75653f6c6f676f3d64617461253341696d616765253246737667253242786d6c2533426261736536342532435043464554304e555756424649484e325a79425156554a4d53554d67496930764c31637a517938765246524549464e57527941784c6a45764c30564f496941696148523063446f764c336433647935334d793576636d637652334a686347687059334d7655315a484c7a45754d5339455645517663335a6e4d5445755a48526b496a344e436a77684c533067565842736232466b5a5751676447383649464e57527942535a5842764c4342336433637563335a6e636d56776279356a62323073494652795957357a5a6d39796257566b49474a354f694254566b6367556d56776279424e6158686c6369425562323973637941744c54344b50484e325a79423361575230614430694f444177634867694947686c6157646f644430694f4441776348676949485a705a58644362336739496a41674d4341794e4341794e4349675a6d6c7362443069626d39755a53496765473173626e4d39496d6830644841364c79393364336375647a4d7562334a6e4c7a49774d44417663335a6e496a344b4454786e49476c6b50534a54566b64535a58427658324a6e51324679636d6c6c63694967633352796232746c4c5864705a48526f50534977496938253242436730385a7942705a44306955315a48556d567762313930636d466a5a584a4459584a79615756794969427a64484a766132557462476c755a574e6863443069636d3931626d516949484e30636d39725a5331736157356c616d3970626a3069636d3931626d51694c7a344b4454786e49476c6b50534a54566b64535a58427658326c6a6232354459584a7961575679496a346750484268644767675a6d6c73624331796457786c50534a6c646d56756232526b4969426a62476c774c584a3162475539496d56325a5735765a47516949475139496b30354c6a6b304e544d78494445754d6a56494d5451754d4455314d554d784e5334304d6a4933494445754d6a51354f5467674d5459754e544931494445754d6a51354f5459674d5463754d7a6b784f5341784c6a4d324e6a5579517a45344c6a49354d6941784c6a51344e7a5530494445354c6a41304f546b674d5334334e4459304d7941784f5334324e544534494449754d7a51344d7a56444d6a41754d6a557a4f4341794c6a6b314d444933494449774c6a55784d6a59674d7934334d4467784e4341794d4334324d7a4d33494451754e6a41344d6a56444d6a41754e7a55774d6941314c6a51334e544979494449774c6a63314d4449674e6934314e7a63314e4341794d4334334e544179494463754f5451314d544e574d5459754d4455304f554d794d4334334e544179494445334c6a51794d6a55674d6a41754e7a55774d6941784f4334314d6a5134494449774c6a597a4d7a63674d546b754d7a6b784f454d794d4334314d544932494449774c6a49354d546b674d6a41754d6a557a4f4341794d5334774e446b33494445354c6a59314d5467674d6a45754e6a55784e304d784f5334774e446b35494449794c6a49314d7a59674d5467754d6a6b79494449794c6a55784d6a55674d5463754d7a6b784f5341794d6934324d7a4d31517a45324c6a55794e5341794d6934334e5341784e5334304d6a4932494449794c6a6331494445304c6a41314e5445674d6a49754e7a56494f5334354e44557a4d6b4d344c6a55334e7a637a494449794c6a6331494463754e4463314e4341794d6934334e5341324c6a59774f445130494449794c6a597a4d7a56444e5334334d44677a4d7941794d6934314d544931494451754f5455774e4455674d6a49754d6a557a4e6941304c6a4d304f445530494449784c6a59314d5464444d7934334e4459324d6941794d5334774e446b3349444d754e4467334e7a4d674d6a41754d6a6b784f53417a4c6a4d324e6a6378494445354c6a4d354d5468444d79347a4d6a67774d5341784f5334784d444d3549444d754d7a41794d5459674d5467754e7a6b774d69417a4c6a49344e446b674d5467754e4451354e454d7a4c6a49304e546779494445344c6a4d794e69417a4c6a497a4f444978494445344c6a45354d5449674d7934794e6a67354e5341784f4334774e545934517a4d754d6a55774d5459674d5463754e4459304f53417a4c6a49314d444533494445324c6a63354f5445674d7934794e5441784f5341784e6934774e545135566a63754f5451314d544e444d7934794e5441784e7941324c6a55334e7a553049444d754d6a55774d5455674e5334304e7a55794d69417a4c6a4d324e6a6378494451754e6a41344d6a56444d7934304f4463334d79417a4c6a63774f44453049444d754e7a51324e6a49674d6934354e5441794e7941304c6a4d304f445530494449754d7a51344d7a56444e4334354e5441304e5341784c6a63304e6a517a494455754e7a41344d7a4d674d5334304f4463314e4341324c6a59774f44517a494445754d7a59324e544a444e7934304e7a5530494445754d6a51354f5459674f4334314e7a63334d6941784c6a49304f546b3449446b754f5451314d7a45674d5334794e56704e4e4334334e7a59354e4341784f4334794e446b78517a51754e7a6b794d5451674d5467754e6a41794f5341304c6a67784e546b33494445344c6a6b784e4341304c6a67314d7a4d7a494445354c6a45354d546c444e4334354e5445354f5341784f5334354d6a5533494455754d544d794e444d674d6a41754d7a45304d6941314c6a51774f5449674d6a41754e546b78517a55754e6a67314f5459674d6a41754f4459334f4341324c6a41334e44557a494449784c6a41304f4449674e6934344d44677a4d5341794d5334784e445935517a63754e54597a4e6a59674d6a45754d6a51344e4341344c6a55324e446333494449784c6a4931494445774c6a41774d4449674d6a45754d6a56494d5451754d4441774d6b4d784e5334304d7a5532494449784c6a4931494445324c6a517a4e6a63674d6a45754d6a51344e4341784e7934784f544978494449784c6a45304e6a6c444d5463754f5449314f4341794d5334774e446779494445344c6a4d784e4451674d6a41754f4459334f4341784f4334314f544579494449774c6a55354d554d784f4334334f446331494449774c6a4d354e4463674d5467754f544d314d7941794d4334784e444978494445354c6a417a4f546b674d546b754e7a56494f4334774d4441784f554d334c6a55344e546b33494445354c6a6331494463754d6a55774d546b674d546b754e4445304d6941334c6a49314d44453549444535517a63754d6a55774d546b674d5467754e5467314f4341334c6a55344e546b33494445344c6a4931494467754d4441774d546b674d5467754d6a56494d546b754d6a497a4e454d784f5334794e444535494445334c6a67784f5341784f5334794e446333494445334c6a4d794e4459674d546b754d6a51354e4341784e6934334e5567334c6a67354e7a6b32517a59754f5445354e7a45674d5459754e7a55674e6934314e7a6333494445324c6a63314e6a51674e69347a4d5455324d6941784e6934344d6a5933517a55754e546b324d7941784e7934774d546b30494455754d4449794f4459674d5463754e5455304d5341304c6a63334e6a6b30494445344c6a49304f544661545445354c6a49314d4449674d5455754d6a56494e7934344f5463354e6b4d334c6a67314f446335494445314c6a4931494463754f4449774d6941784e5334794e5341334c6a63344d6a4533494445314c6a4931517a59754f5459304d6941784e5334794e446b33494459754e4441324d4455674d5455754d6a51354e5341314c6a6b794e7a4d35494445314c6a4d334e7a68444e5334304f546b304d5341784e5334304f544931494455754d5441794e4449674d5455754e6a63354f4341304c6a63314d444535494445314c6a6b794e546c574f454d304c6a63314d444535494459754e5459304e5467674e4334334e5445334f4341314c6a55324d7a5133494451754f44557a4d7a4d674e4334344d4467784d6b4d304c6a6b314d546b35494451754d4463304d7a55674e5334784d7a49304d79417a4c6a59344e546333494455754e4441354d69417a4c6a51774f544178517a55754e6a67314f5459674d7934784d7a49794e5341324c6a41334e44557a494449754f5455784f4341324c6a67774f444d78494449754f44557a4d5456444e7934314e6a4d324e6941794c6a63314d545535494467754e5459304e7a63674d6934334e5341784d4334774d444179494449754e7a56494d5451754d4441774d6b4d784e5334304d7a5532494449754e7a55674d5459754e444d324e7941794c6a63314d545535494445334c6a45354d6a45674d6934344e544d784e554d784e7934354d6a5534494449754f5455784f4341784f43347a4d54513049444d754d544d794d6a55674d5467754e546b784d69417a4c6a51774f544178517a45344c6a67324e7a6b674d7934324f4455334e7941784f5334774e446730494451754d4463304d7a55674d546b754d545133494451754f4441344d544a444d546b754d6a51344e6941314c6a55324d7a5133494445354c6a49314d4449674e6934314e6a51314f4341784f5334794e544179494468574d5455754d6a5661545463754d6a55774d546b674e304d334c6a49314d444535494459754e5467314e7a6b674e7934314f4455354e7941324c6a4931494467754d4441774d546b674e6934794e5567784e6934774d444179517a45324c6a51784e4451674e6934794e5341784e6934334e544179494459754e5467314e7a6b674d5459754e7a55774d694133517a45324c6a63314d4449674e7934304d5451794d5341784e6934304d545130494463754e7a55674d5459754d4441774d6941334c6a6331534467754d4441774d546c444e7934314f4455354e7941334c6a6331494463754d6a55774d546b674e7934304d5451794d5341334c6a49314d44453549446461545463754d6a55774d546b674d5441754e554d334c6a49314d444535494445774c6a41344e5467674e7934314f4455354e7941354c6a6331494467754d4441774d546b674f5334334e5567784d7934774d444179517a457a4c6a51784e4451674f5334334e5341784d7934334e544179494445774c6a41344e5467674d544d754e7a55774d6941784d433431517a457a4c6a63314d4449674d5441754f5445304d6941784d7934304d545130494445784c6a49314944457a4c6a41774d4449674d5445754d6a56494f4334774d4441784f554d334c6a55344e546b33494445784c6a4931494463754d6a55774d546b674d5441754f5445304d6941334c6a49314d444535494445774c6a56614969426d615778735053496a5a6d5a6d496938253242494477765a7a344b4454777663335a6e5067253344253344266c6162656c436f6c6f723d67726579)](https://samuel-gfeller.ch/docs)[![Latest Version on Packagist](https://camo.githubusercontent.com/c1c9807c9bc9c3760f6684f5bd1ba1d174101e469b68aa2ca714906c48992cdc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73616d75656c6766656c6c65722f736c696d2d6170692d737461727465722e737667)](https://packagist.org/packages/samuelgfeller/slim-api-starter)[![Code Coverage](https://camo.githubusercontent.com/e98d6e51ae95b7b4deb3fa17fde0aeed5f9f756c0b64234dee09d8ad8d3b1919/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d75656c6766656c6c65722f736c696d2d6170692d737461727465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samuelgfeller/slim-api-starter/?branch=master)[![Build Status](https://camo.githubusercontent.com/53c362d7a857f7b4d07d59ca0aa446bcbbd2a3a6bce667d640aefb551a929ef9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d75656c6766656c6c65722f736c696d2d6170692d737461727465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samuelgfeller/slim-api-starter/build-status/master)[![Quality Score](https://camo.githubusercontent.com/9d85541587bbe3fc1ee1848802782b279bf09aed61cb649e055403352c10b10a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f73616d75656c6766656c6c65722f736c696d2d6170692d737461727465722e737667)](https://scrutinizer-ci.com/g/samuelgfeller/slim-api-starter/?branch=master)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/samuelgfeller/slim-example-project/blob/master/LICENSE)

[Slim 4](https://www.slimframework.com/) API starter template with a few examples and some essential [features](#features) to help you build a secure and scalable API following current best practices and [SOLID](https://en.wikipedia.org/wiki/SOLID) principles.

An extensive [**documentation**](https://samuel-gfeller.ch/docs) explains the [architecture](https://samuel-gfeller.ch/docs/Architecture), components, design choices (i.e. [SRP](https://samuel-gfeller.ch/docs/Single-Responsibility-Principle-(SRP))) and features.

Features
--------

[](#features)

- [Dependency Injection](https://samuel-gfeller.ch/docs/Dependency-Injection) - [PHP-DI](https://php-di.org/)
- [Database migrations](https://samuel-gfeller.ch/docs/Database-Migrations) - [Phinx](https://phinx.org/)
- [Validation](https://samuel-gfeller.ch/docs/Validation) - [cakephp/validation](https://book.cakephp.org/4/en/core-libraries/validation.html)
- [Logging](https://samuel-gfeller.ch/docs/Logging) - [Monolog](https://github.com/Seldaek/monolog)
- [Query Builder](https://samuel-gfeller.ch/docs/Repository-and-Query-Builder) - [cakephp/database](https://book.cakephp.org/5/en/orm/query-builder.html)
- [Integration testing](https://samuel-gfeller.ch/docs/Writing-Tests) - [PHPUnit](https://github.com/sebastianbergmann/phpunit/)
- [Error handling](https://samuel-gfeller.ch/docs/Error-Handling)
- [GitHub Actions](https://samuel-gfeller.ch/docs/GitHub-Actions) - [Scrutinizer](https://scrutinizer-ci.com/)
- [Coding standards fixer](https://samuel-gfeller.ch/docs/Coding-Standards-Fixer) - [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
- [Static code analysis](https://samuel-gfeller.ch/docs/PHPStan-Static-Code-Analysis) - [PHPStan](https://github.com/phpstan/phpstan)

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

[](#requirements)

- PHP 8.2+
- [Composer](https://samuel-gfeller.ch/docs/Composer)
- MariaDB or MySQL database

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

[](#installation)

#### 1. Create project

[](#1-create-project)

Navigate to the directory you want to create the project in and run the following command, replacing project-name with the desired name for your project.

```
composer create-project samuelgfeller/slim-api-starter project-name
```

This will create a new directory with the specified name and install all necessary dependencies.

#### 2. Set up the database

[](#2-set-up-the-database)

Open the project and rename the file `config/env/env.example.php` to `config/env/env.php`and add the local database credentials.

Then, create the database for the project and update the `config/env/env.dev.php`file with the name of the database, like this:

```
$settings['db']['database'] = 'my_dev_database_name';
```

After that, create a separate database for testing and update the `config/env/env.test.php`file with its name. The name must contain the word "test". There is a safety measure to prevent accidentally truncating the development database while testing:

```
$settings['db']['database'] = 'my_dev_database_name_test';
```

#### 3. Run migrations

[](#3-run-migrations)

Open the terminal in the project's root directory and run the following command to create the demo table `user`:

```
composer migrate
```

#### 4. Insert demo data

[](#4-insert-demo-data)

Four demo users can be inserted into the database to test the API response by running the following command:

```
composer seed
```

#### 5. Update GitHub workflows

[](#5-update-github-workflows)

To run the project's tests automatically when pushing, update the `.github/workflows/build.yml` file.
Replace the matrix value "test-database" with the name of your test database as specified in `config/env/env.test.php`.

If you don't plan on using Scrutinizer, remove the `.scrutinizer` file at the root of the project, otherwise you can follow this [guide](https://samuel-gfeller.ch/docs/How-to-set-up-Scrutinizer)on how to set it up.

#### Done!

[](#done)

That's it! Your project should now be fully set up and ready to use.
If you are using XAMPP and installed the project in the `htdocs` folder, you can access it in the browser at `http://localhost/project-name`.
Or you can serve it locally by running `php -S localhost:8080 -t public/` in the project's root directory.

Support
-------

[](#support)

If you value this project and want to support it, star it on GitHub or visit the [Support❤️](https://samuel-gfeller.ch/docs/Support%E2%9D%A4%EF%B8%8F) page. (thank you!)

License
-------

[](#license)

This project is licensed under the MIT License — see the [LICENSE](https://github.com/samuelgfeller/slim-api-starter/blob/master/LICENSE) file for details.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance42

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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 ~304 days

Total

2

Last Release

464d ago

Major Versions

1.0.0 → 4.0.02025-01-31

### Community

Maintainers

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

---

Top Contributors

[![samuelgfeller](https://avatars.githubusercontent.com/u/31797204?v=4)](https://github.com/samuelgfeller "samuelgfeller (22 commits)")

---

Tags

api-skeletonapi-starterphprest-apislimslim-skeletontemplate-project

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/samuelgfeller-slim-api-starter/health.svg)

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

###  Alternatives

[odan/slim4-skeleton

A Slim 4 skeleton

4588.5k](/packages/odan-slim4-skeleton)[partitech/php-mistral

Connect to Mistral | Anthropic | Xai | Hugging Face | LamaC++ | Vllm | Ollama

2624.1k1](/packages/partitech-php-mistral)[antcool/easy-lark

PHP SDK for Lark

583.1k](/packages/antcool-easy-lark)

PHPackages © 2026

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