Download the PHP package ttpryg/slim-api-starter without Composer
On this page you can find all versions of the php package ttpryg/slim-api-starter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ttpryg/slim-api-starter
More information about ttpryg/slim-api-starter
Files in ttpryg/slim-api-starter
Package slim-api-starter
Short Description Slim 4 API Starter with PHP 8.2 and Docker
License proprietary
Informations about the package slim-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
Key Features & Technologies
- PHP 8.2
- Slim Framework 4 & Slim PSR-7
- PHP-DI 7 (Dependency Injection)
- Eloquent ORM (Database Management)
- Illuminate Database (Database Migrations & Schema Builder)
- Symfony Console (Custom CLI Generator)
- Monolog (File-based Error Logging)
- Laravel Pint (Code Styling & Formatting)
- PHPUnit (Testing)
- Docker & Nginx
- Health Check Endpoint (
GET /health) — Database ping & storage writability check
How to Run
- Clone/Download this project.
-
Start the container with Docker Compose:
-
Install dependencies using composer (inside the container):
- Access the API at URL:
http://localhost:8080
Application Logging
This starter comes pre-configured with Monolog (RotatingFileHandler) for error and debug logging.
- Any unhandled exceptions or internal Slim errors will be automatically logged to:
storage/logs/app-YYYY-MM-DD.log(rotated daily, max 14 files retained) - You can inject
Psr\Log\LoggerInterfaceinto your actions to log custom messages manually:
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:
Generator Commands
-
Make a New Action: Generates an Action class in PascalCase format and automatically uses
ResponseTrait. -
Make a New Model: Generates an Eloquent Model with the appropriate format.
-
Run Migrations: Runs all pending database migrations.
-
Rollback Migrations: Rolls back the last batch of migrations.
-
Make a New Migration: Generates a new migration class using Illuminate Schema Builder.
-
Run Seeders: Runs all database seeders.
- Create a Seeder: Generates a new database seeder class.
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
All test files are placed in the tests/ directory and tested using PHPUnit.
Architectural Notes
ADR Pattern (Action-Domain-Response)
This project uses the ADR pattern as an alternative to conventional MVC for API endpoints:
- Each class in
app/Actionacts 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
ResponseTraitwhich centralizes JSON payload creation ($this->success()and$this->error()methods).
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
All versions of slim-api-starter with dependencies
firebase/php-jwt Version ^7.1
illuminate/database Version ^11.0
illuminate/events Version ^11.0
illuminate/pagination Version ^11.51
league/fractal Version ^0.21.0
monolog/monolog Version ^3.10
php-di/php-di Version ^7.0
slim/psr7 Version ^1.6
slim/slim Version ^4.12
symfony/console Version ^7.4
symfony/validator Version ^7.4
ttpryg/config Version dev-develop
vlucas/phpdotenv Version ^5.6