daranger / php-starter
A modern PHP starter kit with MVC.
Requires
- php: >=8.1
- chillerlan/php-qrcode: ^6.0
- phpmailer/phpmailer: ^7.1
- predis/predis: ^3.5
- robthree/twofactorauth: ^3.0
Requires (Dev)
- phpunit/phpunit: ^11.5
README
A modern, lightweight PHP starter kit and micro-framework with a built-in admin panel, MVC architecture, and Docker support. Designed as a robust foundation for building secure and scalable web applications without the overhead of heavy frameworks.
Core Features & Architecture
🛠️ Custom MVC Micro-framework
Built from scratch with zero heavy dependencies to keep the application blazing fast:
- Routing Engine — Supports GET, POST, route groups, prefixes, and parameter extraction.
- Dependency Injection Container — Intelligent container featuring autowiring via Reflection. Resolves dependencies recursively and supports singletons (
getInstance()->bind(...)). - Middleware Pipeline — Clean request filtering before hitting controllers. Includes built-in
AuthMiddleware,AdminMiddleware(with dynamic IP whitelisting), andCsrfMiddleware.
🛡️ Security & Authentication
- Secure Sessions — Stored in Redis with automatic TTL for performance and security.
- CSRF Protection — Integrated middleware automatically generates and validates
_csrftokens on every POST request. - Authentication — Bcrypt hashed passwords, rate-limiting against brute force, and ready-to-use 2FA logic.
- Role-based Access Control (RBAC) — Distinct permissions for regular users and administrators.
🌐 Localization (i18n)
- Built-in Translation System — A robust helper
__('key')maps dictionary files from thelang/directory to strings in the current user's locale. - Session & DB tied — Language preferences persist across sessions.
🎨 Themes & UI
- Dark & Light Modes — Native support for theme switching out of the box.
- Dynamic Settings — App name, mail host, UI settings are driven by the
settingsdatabase table, configurable directly from the Admin Panel instead of hardcoded.envfiles.
📋 Logging & Telemetry
- Database & File Logging — User actions (
user_logs) and daemon background jobs (daemon_jobs_log) are tracked. - System Dashboard — Built-in
SystemServicethat tracks server metrics (RAM, Disk, CPU Load Average, Uptime) and outputs them to the admin dashboard.
🐳 Docker Ready
- Comes with a complete
docker-compose.ymlfor instant local development. - Bundles Nginx, PHP-FPM 8.2, MySQL 8.0, and Redis 7.2.
Stack
| Layer | Technology |
|---|---|
| Language | PHP 8.1+ |
| Web server | Nginx (via Docker) / Apache |
| Database | MySQL 8.0 / MariaDB |
| Cache / Sessions | Redis (Predis) |
| PHPMailer | |
| Framework | Custom MVC (Container, Router, Middleware) |
| Tests | PHPUnit 11 |
Requirements
- PHP 8.1+ (if running bare-metal)
- Composer
- MySQL 8.0+ or MariaDB
- Redis server
- Or simply Docker & Docker Compose for local development.
Installation via Composer
The easiest way to start a new project is via Composer:
composer create-project daranger/php-starter my-new-app
cd my-new-app
Composer will automatically clone the repository, remove the git history, and install all dependencies.
Installation via Docker (Alternative)
-
Clone the repository
git clone https://github.com/daranger/php-starter.git cd php-starter -
Setup environment
cp .env.example .env # Edit .env to set your database credentials if needed -
Start the containers
docker-compose up -d
-
Install PHP dependencies
docker-compose exec app composer install -
Run migrations & seed
# Make sure to run your database migrations/seeds here # e.g., import database/Migrations/*.sql
-
Access the application Open your browser and navigate to
http://localhost.
Testing
The framework includes a comprehensive test suite powered by PHPUnit.
composer dump-autoload vendor/bin/phpunit
License
This project is licensed under the MIT License — see the LICENSE file for details.



