Skip to main content
All configuration for MINI is stored in a single file: application/config/config.php. This guide explains every configuration option available.

Configuration File Overview

The config file uses PHP constants defined with define() for configuration values:
application/config/config.php
define('SETTING_NAME', 'value');
Constants are used instead of variables because they cannot be accidentally changed during runtime, making your application more secure and predictable.

Environment Settings

Error Reporting

Control how PHP errors are displayed:
application/config/config.php
define('ENVIRONMENT', 'development');

if (ENVIRONMENT == 'development' || ENVIRONMENT == 'dev') {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}
define('ENVIRONMENT', 'development');
Behavior:
  • Shows all errors and warnings
  • Displays errors directly on the page
  • Useful for debugging during development
Never use development mode in production! It exposes sensitive information to users.

Error Reporting Levels

// Show all errors (development)
error_reporting(E_ALL);

// Show only fatal errors (production)
error_reporting(E_ERROR | E_PARSE);

// Show errors but not notices
error_reporting(E_ALL & ~E_NOTICE);

// Show no errors (not recommended)
error_reporting(0);

URL Configuration

MINI automatically detects your application’s URL structure:
application/config/config.php
define('URL_PUBLIC_FOLDER', 'public');
define('URL_PROTOCOL', '//');
define('URL_DOMAIN', $_SERVER['HTTP_HOST']);
define('URL_SUB_FOLDER', str_replace(URL_PUBLIC_FOLDER, '', dirname($_SERVER['SCRIPT_NAME'])));
define('URL', URL_PROTOCOL . URL_DOMAIN . URL_SUB_FOLDER);

Understanding URL Components

The name of the public folder that contains index.php.
define('URL_PUBLIC_FOLDER', 'public');
Default: publicChange if: You renamed the public folder
// If you renamed it to 'web'
define('URL_PUBLIC_FOLDER', 'web');
The protocol part of the URL.
define('URL_PROTOCOL', '//');
Default: // (protocol-independent)The // notation automatically uses:
  • http:// for non-SSL connections
  • https:// for SSL connections
Manual configuration:
// Force HTTPS
define('URL_PROTOCOL', 'https://');

// Force HTTP (not recommended)
define('URL_PROTOCOL', 'http://');
The domain name from the HTTP request.
define('URL_DOMAIN', $_SERVER['HTTP_HOST']);
Auto-detected examples:
  • localhost
  • localhost:8000
  • example.com
  • www.example.com
Manual override:
// Use specific domain
define('URL_DOMAIN', 'www.example.com');
Automatically detects if your app is in a subdirectory.
define('URL_SUB_FOLDER', str_replace(URL_PUBLIC_FOLDER, '', dirname($_SERVER['SCRIPT_NAME'])));
Examples:
InstallationURL_SUB_FOLDER
http://localhost//
http://localhost/myapp//myapp/
http://example.com//
http://example.com/app//app/
The final, complete base URL for your application.
define('URL', URL_PROTOCOL . URL_DOMAIN . URL_SUB_FOLDER);
Auto-generated examples:
  • //localhost/
  • //localhost/myapp/
  • //example.com/
  • //www.example.com/app/
Manual override (disables auto-detection):
// Override everything
define('URL', 'https://www.example.com/myapp/');

Using the URL Constant

The URL constant is used throughout MINI for creating links:
// In controllers - redirects
header('location: ' . URL . 'songs/index');

// In views - links
<a href="<?php echo URL; ?>songs/index">View Songs</a>

// In views - form actions
<form action="<?php echo URL; ?>songs/addsong" method="POST">

// In JavaScript (defined in footer.php)
var url = "<?php echo URL; ?>";
$.ajax(url + "/songs/ajaxGetStats");

Common URL Configurations

// Usually works automatically
define('URL_PROTOCOL', '//');
define('URL_DOMAIN', $_SERVER['HTTP_HOST']);
// Results in: //localhost/ or //localhost:8000/

Database Configuration

Database connection settings:
application/config/config.php
define('DB_TYPE', 'mysql');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'mini');
define('DB_USER', 'root');
define('DB_PASS', 'your_password');
define('DB_CHARSET', 'utf8');

Database Settings Explained

The PDO driver to use for database connection.
define('DB_TYPE', 'mysql');
Supported values:
  • mysql - MySQL or MariaDB (most common)
  • pgsql - PostgreSQL
  • sqlite - SQLite
Examples:
// PostgreSQL
define('DB_TYPE', 'pgsql');

// SQLite (also change DB_HOST)
define('DB_TYPE', 'sqlite');
define('DB_HOST', '/path/to/database.db');
The hostname or IP address of your database server.
define('DB_HOST', '127.0.0.1');
Common values:
  • 127.0.0.1 - Local MySQL server
  • localhost - Local MySQL server (socket connection)
  • mysql - Docker container name
  • db.example.com - Remote database server
  • 192.168.1.100:3307 - Custom port
The name of the database to connect to.
define('DB_NAME', 'mini');
Must match the database you created during installation.
The username for database authentication.
define('DB_USER', 'root');
Never use root in production! Create a dedicated user with limited permissions.
Production example:
define('DB_USER', 'mini_app_user');
The password for database authentication.
define('DB_PASS', 'your_password');
Use strong passwords in production and consider storing credentials in environment variables instead of the config file.
The character set for database communication.
define('DB_CHARSET', 'utf8');
Recommended values:
  • utf8 - Standard UTF-8 (good for most use cases)
  • utf8mb4 - Full UTF-8 support including emojis
// Support emojis and special characters
define('DB_CHARSET', 'utf8mb4');

Environment-Specific Database Config

Use different database settings for development vs production:
application/config/config.php
if (ENVIRONMENT == 'development') {
    define('DB_HOST', '127.0.0.1');
    define('DB_NAME', 'mini_dev');
    define('DB_USER', 'root');
    define('DB_PASS', '');
} else {
    define('DB_HOST', 'production-db.example.com');
    define('DB_NAME', 'mini_prod');
    define('DB_USER', 'mini_app_user');
    define('DB_PASS', 'secure_production_password');
}

define('DB_TYPE', 'mysql');
define('DB_CHARSET', 'utf8mb4');

Complete Configuration Examples

Development Environment

application/config/config.php
<?php

// Development mode - show all errors
define('ENVIRONMENT', 'development');

if (ENVIRONMENT == 'development' || ENVIRONMENT == 'dev') {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}

// URL - auto-detected
define('URL_PUBLIC_FOLDER', 'public');
define('URL_PROTOCOL', '//');
define('URL_DOMAIN', $_SERVER['HTTP_HOST']);
define('URL_SUB_FOLDER', str_replace(URL_PUBLIC_FOLDER, '', dirname($_SERVER['SCRIPT_NAME'])));
define('URL', URL_PROTOCOL . URL_DOMAIN . URL_SUB_FOLDER);

// Database - local development
define('DB_TYPE', 'mysql');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'mini');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_CHARSET', 'utf8');

Production Environment

application/config/config.php
<?php

// Production mode - hide errors from users
define('ENVIRONMENT', 'production');

if (ENVIRONMENT == 'development' || ENVIRONMENT == 'dev') {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}

// URL - manual for production
define('URL', 'https://www.example.com/');

// Database - production server
define('DB_TYPE', 'mysql');
define('DB_HOST', 'db.example.com');
define('DB_NAME', 'mini_production');
define('DB_USER', 'mini_app_user');
define('DB_PASS', 'secure_production_password_here');
define('DB_CHARSET', 'utf8mb4');

Docker Environment

application/config/config.php
<?php

define('ENVIRONMENT', getenv('APP_ENV') ?: 'production');

if (ENVIRONMENT == 'development' || ENVIRONMENT == 'dev') {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}

// URL from environment variable
define('URL', getenv('APP_URL') ?: '//localhost/');

// Database from Docker environment variables
define('DB_TYPE', 'mysql');
define('DB_HOST', getenv('DB_HOST') ?: 'mysql');
define('DB_NAME', getenv('DB_NAME') ?: 'mini');
define('DB_USER', getenv('DB_USER') ?: 'root');
define('DB_PASS', getenv('DB_PASS') ?: 'root');
define('DB_CHARSET', 'utf8mb4');

Security Best Practices

Add config.php to .gitignore:
.gitignore
application/config/config.php
Create a template file instead:
application/config/config.example.php
<?php
// Copy this file to config.php and update with your settings

define('DB_HOST', 'localhost');
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASS', 'password_here');
Store sensitive data in environment variables:
application/config/config.php
define('DB_PASS', getenv('DB_PASSWORD'));
Set in your server environment:
export DB_PASSWORD="your_secure_password"
Make config.php readable only by the web server:
chmod 600 application/config/config.php
chown www-data:www-data application/config/config.php
Generate secure passwords:
# Generate a random password
openssl rand -base64 32

Accessing Configuration Values

Configuration constants are available throughout your application:
// In controllers
class MyController extends Controller
{
    public function index()
    {
        // Access URL constant
        header('location: ' . URL . 'home/index');
        
        // Check environment
        if (ENVIRONMENT == 'development') {
            // Development-only code
        }
    }
}

// In views
<a href="<?php echo URL; ?>songs/index">Songs</a>

// In JavaScript (footer.php)
var url = "<?php echo URL; ?>";
Database constants (DB_HOST, DB_USER, etc.) are only used in application/core/controller.php for the PDO connection. You typically don’t access them elsewhere.

Troubleshooting

Problem: Cannot connect to database.Solution: Verify credentials:
// Test connection in config.php
try {
    $test = new PDO(
        DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME,
        DB_USER,
        DB_PASS
    );
    echo "Database connection successful!";
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}
exit();
Problem: Error reporting not working.Solution: Check php.ini settings:
// Force error display
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Next Steps

Database Setup

Learn how to set up and use the database

CRUD Operations

Implement Create, Read, Update, Delete functionality

Build docs developers (and LLMs) love