Last updated
INI File Format Structure
The INI File Editor provides a visual interface for editing INI configuration files. Here is the standard INI format with all its elements:
; This is a comment (semicolon style)
# This is also a comment (hash style)
; Global key (no section)
app_name = MyApplication
version = 1.0.0
[database]
host = localhost
port = 3306
name = myapp_db
username = dbuser
password = secretpassword
charset = utf8mb4
[cache]
driver = redis
host = 127.0.0.1
port = 6379
ttl = 3600
prefix = myapp_
[logging]
level = info
file = /var/log/myapp/app.log
max_size = 100MB
rotate = daily
[features]
; Boolean values (various formats accepted)
dark_mode = true
beta_features = false
maintenance_mode = 0
debug = yes
PHP Configuration (php.ini)
PHP's configuration file uses INI format. Here are the most important settings:
[PHP]
; Memory and execution limits
memory_limit = 256M
max_execution_time = 30
max_input_time = 60
; File uploads
file_uploads = On
upload_max_filesize = 64M
post_max_size = 64M
max_file_uploads = 20
; Error handling
error_reporting = E_ALL
display_errors = Off ; Off in production!
display_startup_errors = Off
log_errors = On
error_log = /var/log/php/error.log
; Session configuration
session.save_handler = files
session.save_path = /var/lib/php/sessions
session.gc_maxlifetime = 1440
session.cookie_secure = On ; HTTPS only
session.cookie_httponly = On ; No JavaScript access
session.cookie_samesite = Strict
; OPcache (performance)
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 60
[Date]
date.timezone = America/New_York
[MySQLi]
mysqli.default_host = localhost
mysqli.default_port = 3306
Application Configuration File
A typical application config.ini with multiple sections:
[app]
name = My Web Application
environment = production
debug = false
secret_key = your-secret-key-here
timezone = UTC
locale = en_US
[server]
host = 0.0.0.0
port = 8080
workers = 4
timeout = 30
max_connections = 1000
[database]
driver = postgresql
host = db.example.com
port = 5432
name = production_db
user = app_user
password = db_password
pool_size = 10
pool_timeout = 30
ssl_mode = require
[redis]
host = redis.example.com
port = 6379
password = redis_password
db = 0
max_connections = 50
[email]
driver = smtp
host = smtp.sendgrid.net
port = 587
username = apikey
password = SG.your-sendgrid-api-key
from_address = noreply@example.com
from_name = My Application
encryption = tls
[storage]
driver = s3
bucket = my-app-uploads
region = us-east-1
access_key = AKIAIOSFODNN7EXAMPLE
secret_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
cdn_url = https://cdn.example.com
Reading INI Files in Code
How to parse and use INI configuration files in different languages:
/* PHP — built-in parse_ini_file() */
$config = parse_ini_file('config.ini', true); // true = process sections
echo $config['database']['host']; // localhost
echo $config['app']['name']; // My Web Application
// With type casting
$config = parse_ini_file('config.ini', true, INI_SCANNER_TYPED);
var_dump($config['app']['debug']); // bool(false)
/* Python — configparser module */
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
print(config['database']['host']) # localhost
print(config['app']['debug']) # false (string)
print(config.getboolean('app', 'debug')) # False (bool)
print(config.getint('server', 'port')) # 8080 (int)
# Iterate sections
for section in config.sections():
print(f"[{section}]")
for key, value in config[section].items():
print(f" {key} = {value}")
/* Node.js — ini package */
const ini = require('ini');
const fs = require('fs');
const config = ini.parse(fs.readFileSync('config.ini', 'utf-8'));
console.log(config.database.host); // localhost
console.log(config.server.port); // '8080' (string)
/* Java — java.util.Properties */
Properties props = new Properties();
props.load(new FileInputStream("config.ini"));
String host = props.getProperty("database.host", "localhost");
Common INI Format Variations
Different applications use slightly different INI format conventions:
/* Standard INI (= separator) */
key = value
key=value ; spaces around = are optional
/* Colon separator (some apps use this) */
key: value
host: localhost
port: 3306
/* Multi-line values (leading whitespace = continuation) */
description = This is a long description
that continues on the next line
and even a third line
/* Array values (repeated keys) */
allowed_hosts = localhost
allowed_hosts = 127.0.0.1
allowed_hosts = example.com
/* Array with bracket notation */
extensions[] = php_curl
extensions[] = php_mbstring
extensions[] = php_pdo_mysql
/* Quoted values (for values with special characters) */
password = "p@ssw0rd!with#special&chars"
path = "C:\Program Files\MyApp"
/* Variable interpolation (some parsers support this) */
base_dir = /var/www/myapp
log_dir = ${base_dir}/logs
upload_dir = ${base_dir}/uploads