PHPackages                             ttpryg/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. ttpryg/slim-api-starter

ActiveProject[API Development](/categories/api)

ttpryg/slim-api-starter
=======================

Slim 4 API Starter with PHP 8.2 and Docker

0.0.2(2mo ago)02[4 PRs](https://github.com/ttpryg/slim-api-starter/pulls)PHPPHP ^8.2CI passing

Since Apr 23Pushed 1mo agoCompare

[ Source](https://github.com/ttpryg/slim-api-starter)[ Packagist](https://packagist.org/packages/ttpryg/slim-api-starter)[ RSS](/packages/ttpryg-slim-api-starter/feed)WikiDiscussions develop Synced 3w ago

READMEChangelog (2)Dependencies (10)Versions (7)Used By (0)

Slim 4 API Starter
==================

[](#slim-4-api-starter)

A robust starter project using Slim Framework 4 with PHP 8.2, PHP-DI, Eloquent ORM, and Docker.

Folder Structure
----------------

[](#folder-structure)

```
.
├── app/                # Main application source code
│   ├── Action/         # API Actions (ADR Pattern)
│   ├── Commands/       # CLI Commands (Symfony Console)
│   ├── Model/          # Eloquent Models
│   └── Traits/         # Reusable Traits (e.g., ResponseTrait)
├── config/             # Configuration (Routes, Container, Settings, DB)
├── db/                 # Database Migrations & Seeds
├── public/             # Document root (Entry point index.php)
├── storage/            # Local storage (Logs, Caches, etc.)
│   └── logs/           # Application log files
├── tests/              # Automated testing (PHPUnit)
├── slim                # Executable CLI tool (Symfony Console)
├── Dockerfile          # PHP 8.2-FPM image configuration
├── docker-compose.yml  # Orchestration App & Web Server (Nginx)
└── nginx.conf          # Nginx Configuration

```

Key Features &amp; Technologies
-------------------------------

[](#key-features--technologies)

- **PHP 8.2**
- **Slim Framework 4** &amp; **Slim PSR-7**
- **PHP-DI 7** (Dependency Injection)
- **Eloquent ORM** (Database Management)
- **Illuminate Database** (Database Migrations &amp; Schema Builder)
- **Symfony Console** (Custom CLI Generator)
- **Monolog** (File-based Error Logging)
- **Laravel Pint** (Code Styling &amp; Formatting)
- **PHPUnit** (Testing)
- **Docker &amp; Nginx**

How to Run
----------

[](#how-to-run)

1. **Clone/Download** this project.
2. Start the container with Docker Compose: ```
    docker compose up -d --build
    ```
3. Install dependencies using composer (inside the container): ```
    docker exec -it slim_app composer install
    ```
4. Access the API at URL: `http://localhost:8080`

Application Logging
-------------------

[](#application-logging)

This starter comes pre-configured with **Monolog** for error and debug logging.

- Any unhandled exceptions or internal Slim errors will be automatically logged to: `storage/logs/app.log`
- You can inject `Psr\Log\LoggerInterface` into your actions to log custom messages manually: ```
    public function __construct(private \Psr\Log\LoggerInterface $logger) {}

    public function __invoke(...) {
        $this->logger->info("This is a custom log entry");
    }
    ```

CLI Tool (Slim API Starter)
---------------------------

[](#cli-tool-slim-api-starter)

This project has a built-in CLI (`./slim`) to help accelerate the development process. All CLI commands can be executed inside the container:

```
docker exec -it slim_app php slim list
```

### Generator Commands

[](#generator-commands)

- **Make a New Action**: Generates an Action class in PascalCase format and automatically uses `ResponseTrait`. ```
    php slim make:action User/LoginAction
    ```
- **Make a New Model**: Generates an Eloquent Model with the appropriate format. ```
    php slim make:model User
    ```
- **Run Migrations**: Runs all pending database migrations. ```
    php slim migrate
    ```
- **Rollback Migrations**: Rolls back the last batch of migrations. ```
    php slim migrate:rollback
    php slim migrate:rollback 3   # rollback 3 batches
    ```
- **Make a New Migration**: Generates a new migration class using Illuminate Schema Builder. ```
    php slim make:migration CreateUsersTable
    ```
- **Run Seeders**: Runs all database seeders. ```
    php slim seed:run
    ```
- **Create a Seeder**: Generates a new database seeder class. ```
    php slim seed:create UsersTableSeeder
    ```

Formatting &amp; Code Styling
-----------------------------

[](#formatting--code-styling)

This project is integrated with **Laravel Pint** to maintain code neatness (PSR-12/Laravel Style).

- **Check Code Style**: `composer style-check`
- **Fix Code Style Automatically**: `composer style-fix`

Testing
-------

[](#testing)

All test files are placed in the `tests/` directory and tested using PHPUnit.

```
docker exec -it slim_app composer test
```

Architectural Notes
-------------------

[](#architectural-notes)

### ADR Pattern (Action-Domain-Response)

[](#adr-pattern-action-domain-response)

This project uses the **ADR** pattern as an alternative to conventional MVC for API endpoints:

- Each class in `app/Action` acts independently with **Single Responsibility**.
- Classes are implemented as *invokables* (using the `__invoke()` magic method) so they can be routed dynamically by Slim.
- Output is standardized using `ResponseTrait` which centralizes JSON payload creation (`$this->success()` and `$this->error()` methods).

Common Container Commands
-------------------------

[](#common-container-commands)

- **View App Logs (Docker)**: `docker compose logs -f app`
- **Enter Container Shell**: `docker exec -it slim_app bash`
- **Update Composer**: `docker exec -it slim_app composer update`
- **Refresh Autoloader**: `docker exec -it slim_app composer dump-autoload`

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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 ~20 days

Total

2

Last Release

71d ago

### Community

Maintainers

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

---

Top Contributors

[![totoprayogo1916](https://avatars.githubusercontent.com/u/2387514?v=4)](https://github.com/totoprayogo1916 "totoprayogo1916 (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[laravel/framework

The Laravel Framework.

34.8k543.8M20.5k](/packages/laravel-framework)[showdoc/showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online

12.8k7.1k](/packages/showdoc-showdoc)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)

PHPackages © 2026

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