sonsonyyy / slim-api-starter
A modern API-first starter kit for Slim Framework 4.
Package info
github.com/sonsonyyy/slim-api-starter
Type:project
pkg:composer/sonsonyyy/slim-api-starter
Requires
- php: ^8.4
- ext-pdo: *
- doctrine/orm: ^3.6
- php-di/php-di: ^7.1
- robmorgan/phinx: ^0.16.12
- slim/psr7: ^1.8
- slim/slim: 4.*
- symfony/property-access: ^8.1
- symfony/validator: ^8.1
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- pestphp/pest: ^5.1
- phpstan/phpstan: ^2.2
- squizlabs/php_codesniffer: ^4.0
Suggests
- ext-pdo_mysql: Required when using MySQL as the database driver.
- ext-pdo_pgsql: Required when using PostgreSQL as the database driver.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-10 17:44:28 UTC
README
A modern API-first starter kit for Slim Framework 4.
Slim API Starter is an opinionated Slim Framework starter project designed for building clean, maintainable REST APIs with database support, migrations, validation, dependency injection, logging, and Pest testing ready out of the box.
Features
- Slim Framework 4
- API-first project structure
- Modular layered architecture
- PHP-DI dependency injection container
- Environment configuration using
.env - PostgreSQL and MySQL database support
- Doctrine ORM via
doctrine/orm - Request validation using
symfony/validator - Phinx database migrations
- Monolog logging
- Pest testing by default
- PHPStan static analysis
- PHP CS Fixer code formatting
- Example health check endpoint
Architectural Style
This starter uses a Modular Layered Architecture.
The goal is to provide a clean structure without making the application too complex for small and medium-sized APIs.
Each module may contain its own actions, services, routes, and related classes. Shared application concerns such as middleware, validation, responses, exceptions, and database configuration are placed in shared folders.
Recommended responsibility flow:
Route → Action/Controller → Service → Repository/Model → Database
Why Modular Layered Architecture?
Slim is a lightweight microframework. It gives developers flexibility, but without a good structure, applications can quickly become hard to maintain.
This starter provides a practical structure where:
- routes define API endpoints
- actions/controllers handle HTTP requests and responses
- services contain business logic
- repositories or models handle database access
- validators handle request validation
- middleware handles cross-cutting HTTP concerns
- configuration stays outside business logic
- tests are organized by behavior and unit scope
Recommended Use Cases
This starter is ideal for:
- REST API projects
- small to medium-sized backend services
- learning Slim Framework
- API prototypes
Package Type
This package is intended to be installed as a project:
composer create-project sonsonyyy/slim-api-starter my-api
License
This project is open-sourced software licensed under the MIT license.