Folder Structure

Understanding the folder structure is essential for working with the Mini Framework. This guide explains where to place your files and what each directory is for.

Project Structure

project/
├── app/                    # Application code
│   ├── Controllers/        # Controller classes
│   ├── Models/            # Model classes
│   ├── Views/             # View templates
│   │   ├── components/    # Reusable components
│   │   └── layouts/       # Layout templates
│   ├── Middleware/        # Middleware classes
│   └── Helpers/           # Helper functions
├── core/                  # Framework core files
│   ├── App.php           # Application bootstrap
│   ├── Router.php        # Routing system
│   ├── Route.php         # Route facade
│   ├── Controller.php    # Base controller
│   ├── Model.php         # Base model
│   ├── View.php          # View renderer
│   ├── Request.php       # Request handler
│   ├── Response.php      # Response handler
│   └── Middleware.php    # Base middleware
├── config/               # Configuration files
│   └── database.php      # Database configuration
├── routes/               # Route definitions
│   └── web.php          # Web routes
├── public/               # Public web root
│   ├── index.php        # Entry point
│   └── .htaccess        # Apache configuration
├── docs/                 # Documentation (this site)
└── mini                  # CLI tool

Directory Details

app/

This is where all your application code lives. It contains your controllers, models, views, and middleware.

app/Controllers/

Place all your controller classes here. Controllers handle HTTP requests and return responses.

app/Controllers/
├── HomeController.php
├── UserController.php
└── ProductController.php

app/Models/

Your model classes go here. Models interact with the database.

app/Models/
├── User.php
├── Product.php
└── Order.php

app/Views/

All view templates are stored here. Views can be organized in subdirectories.

app/Views/
├── home.php              # Main views
├── user/
│   ├── profile.php
│   └── settings.php
├── components/           # Reusable components
│   ├── navbar.php
│   └── footer.php
└── layouts/             # Layout templates
    └── main.php

app/Middleware/

Middleware classes for authentication, authorization, and request processing.

app/Middleware/
├── AuthMiddleware.php
├── AdminMiddleware.php
└── GuestMiddleware.php

core/

The framework's core files. Do not modify these files unless you're extending the framework. Instead, extend the base classes in your app/ directory.

⚠️ Important: Modifying core files directly can break your application when updating the framework. Always extend base classes instead.

App.php - Main application class that bootstraps the framework

Router.php - Handles route registration and matching

Route.php - Route facade for static route definitions

Controller.php - Base controller class

Model.php - Base model class with PDO integration

View.php - View rendering system

Request.php - HTTP request handler

Response.php - HTTP response handler

Middleware.php - Base middleware class

config/

Configuration files for your application. Currently includes database configuration.

config/
└── database.php    # Database connection settings

routes/

Define all your application routes here. The web.php file contains your web routes.

routes/
└── web.php    # All web routes defined here

public/

This is your web server's document root. All public assets (CSS, JS, images) should be placed here. The index.php file is the entry point for all requests.

public/
├── index.php      # Application entry point
├── .htaccess      # Apache URL rewriting
├── css/           # Stylesheets
├── js/            # JavaScript files
└── images/        # Image assets

Naming Conventions

Controllers

Use PascalCase with "Controller" suffix: UserController.php, ProductController.php

Models

Use PascalCase: User.php, Product.php

Views

Use lowercase with underscores: user_profile.php, product_list.php

Middleware

Use PascalCase with "Middleware" suffix: AuthMiddleware.php, AdminMiddleware.php

Next Steps

Now that you understand the folder structure, learn how to: