gruxlolo-dev / sterslim
PHP Starter Kit - lightweight framework skeleton with Docker and Attribute Routing
Requires
- php: ^8.2
- illuminate/database: ^10.0
- slim/psr7: ^1.5
- slim/slim: ^4.0
- vlucas/phpdotenv: ^5.5
Suggests
- mongodb/mongodb: Required to use MongoDB with Eloquent (^1.16)
README
Sterslim is a high-performance, lightweight PHP Starter Kit built on top of the Slim 4 Framework. It provides a modern, "Laravel-like" developer experience with a fraction of the weight, featuring an interactive CLI, automated Docker environment, and attribute-based routing.
✨ Key Features
- 💻 Sterslim CLI: A powerful command-line tool for scaffolding and project management.
- 🛣️ Attribute Routing: Define your routes directly in controllers using PHP 8 attributes.
- 🐳 Dockerized: Production-ready Apache + PHP 8.2 setup with automated
.envanddocker-compose.ymlgeneration. - 🏗️ Smart Scaffolding: Generate Controllers, Services, and Middlewares with one command.
- 🗄️ Eloquent ORM: Full support for MySQL, MariaDB, PostgreSQL, and MongoDB.
- 🛡️ Secure by Default: Hardened Apache configuration protecting your system files and serving only the
public/directory.
📦 Installation
Create a new project using Composer:
composer create-project gruxlolo-dev/sterslim my-app
Note: The interactive installer will start automatically to configure your database and Docker environment.
🛠️ The Sterslim CLI
Manage your application with the built-in CLI tool:
| Command | Description |
|---|---|
php sterslim create module [Name] |
Generates Controller, Service, and Middleware. |
php sterslim create controller [Name] |
Generates a new API Controller. |
php sterslim create service [Name] |
Generates a new Service class. |
php sterslim create middleware [Name] |
Generates a new Middleware. |
php sterslim list routes |
Lists all discovered routes and endpoints. |
php sterslim install |
Re-runs the interactive installer. |
🚀 Usage Guide
1. Defining Routes
Stop hunting through routing files. Define routes directly where they belong:
namespace App\Controllers; use App\Attributes\Route; use App\Middlewares\AuthMiddleware; class UserController { #[Route(path: "/api/users", method: "GET", middleware: [AuthMiddleware::class])] public function index($request, $response) { // Your logic here return $response->withHeader('Content-Type', 'application/json'); } }
2. Layered Architecture
Generated modules follow a clean structure:
- Controllers: Handle HTTP requests and JSON responses.
- Services: Contain business logic and database interactions.
- Middlewares: Handle cross-cutting concerns (Auth, Validation, CORS).
3. Database & Docker
Start your development environment with a single command:
docker-compose up -d
Access your application at http://localhost:8080.
📂 Project Structure
├── bootstrap/ # App initialization & DB setup
├── config/ # Configuration files
├── installer/ # Interactive setup scripts
├── public/ # Web server root (index.php, .htaccess)
├── src/
│ ├── Attributes/ # Custom PHP Attributes
│ ├── Controllers/ # API Controllers
│ ├── Middlewares/ # Application Middlewares
│ ├── Routing/ # Route Discovery Engine
│ └── Services/ # Business Logic / Services
└── sterslim # Main CLI Tool
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Developed with ❤️ by gruxlolo-dev