How thecodeholic/php-mvc-framework works
Project type and purpose
• This is a minimalistic PHP MVC web application/framework meant for educational use.
• It follows the classic Model-View-Controller pattern, uses Composer for dependency management, and supports Docker for local development.
• It provides basic user registration, login, profile, and static pages (about, contact).
File structure
• Top-level files:
• docker-compose.yml + docker/ – Docker setup for “app” (PHP+Apache) and “db” (MySQL).
• migrations.php + migrations/ – CLI script and migration files to create/alter the database.
• composer.json – PHP dependencies, including a core MVC package.
• .env.example – environment variables for database credentials.
• Directories:
• public/ – Web root; .htaccess + index.php (front controller) + assets (css).
• controllers/ – Controller classes handling HTTP requests.
• models/ – Domain models (e.g., User, LoginForm).
• views/ – Twig-style PHP templates, organized by layouts and pages.
• runtime/ – Temporary files.
README for additional insights
• Confirms MVC pattern, Composer setup, migrations flow, and Docker-based dev environment.
a. Main components
• Client (Browser)
• Docker Network
– Web Server Container (“app”): Apache+PHP
– Database Container (“db”): MySQL
• PHP MVC Application
– Front Controller (public/index.php)
– Router & Dispatcher (core package)
– Controllers
– Models (with migrations as a CLI sub-component)
– Views (templates + static assets)
• External Dependencies: Composer packages, .env configuration
b. Relationships and interactions
1. Browser sends HTTP request → Web Server (Docker “app”) on port 8080
2. Apache routes all requests to public/index.php
3. Front Controller loads .env, bootstraps core package
4. Router matches URL to a Controller action
5. Controller:
– Reads request data
– Invokes Models to query/update MySQL over Docker network
– Loads a View template, passes model data
6. View renders HTML → Apache → Browser
c. Architectural patterns & principles
• MVC separation of concerns
• Front Controller pattern
• Dependency Injection via Composer + core package
• Configuration via environment variables (.env)
• Infrastructure-as-code with Docker Compose
d. Key technologies & libraries
• PHP 7+ / Apache (in Docker)
• MySQL (in Docker)
• Composer (tc-php-mvc-core package)
• .env for configuration
• migrations.php as a lightweight migration runner