Configuration
Introduction
Config holds the plugin's identity — slug, prefixes, versions — and derives paths from them. plugin:init fills the values in when you scaffold, so you rarely edit the class itself, but almost every other example on this site calls it.
Constants
use YourPlugin\Config;
Config::SLUG; // 'your-plugin'
Config::TITLE; // 'Your Plugin'
Config::VERSION; // '1.0.0'
Config::DB_VERSION; // schema version, drives migrations on upgrade
Config::VAR_PREFIX; // 'YOUR_PLUGIN_' — prefix for options, hooks, nonces
Config::CLASS_PREFIX;
Config::REST_NAMESPACE;
Config::API_VERSION;
Config::ASSETS_FOLDER;
Config::REQUIRED_PHP_VERSION;
Config::REQUIRED_WP_VERSION;
Prefixing
Everything the plugin writes into a shared WordPress namespace — options, hook tags, nonce actions — goes through a prefix so it cannot collide with another plugin:
Config::withPrefix('nonce'); // YOUR_PLUGIN_nonce
Config::withDBPrefix('flows'); // wp_YOUR_PLUGIN_flows
That is why nonce verification and custom hook tags are written as Config::withPrefix(...) rather than as literals.
Options
The option helpers apply the same prefix, so you name an option once and never repeat the prefix:
Config::getOption('settings', $default); // get_option('YOUR_PLUGIN_settings', ...)
Config::addOption('settings', $value);
Config::updateOption('settings', $value);
Config::deleteOption('settings');
Pass true as the third argument to getOption() to read an unprefixed WordPress option instead.
Paths
Config::get() derives paths and URLs from the plugin's main file, so nothing hard-codes a directory:
Config::get('MAIN_FILE'); // absolute path to the plugin entry file
Config::get('BASENAME'); // your-plugin/your-plugin.php
Config::get('ROOT_DIR'); // plugin directory
Config::get('BASEDIR'); // the backend/ directory
Config::get('UPLOAD_BASE_DIR'); // wp-content/uploads path
Config::get('UPLOAD_BASE_URL'); // wp-content/uploads URL
Environment variables
Dotenv::load() reads .env from the plugin root during bootstrap. Copy the example file to start:
cp .env.example .env
DEV = true # dev mode
CLI_ACTIVE = true # enable the WP-CLI commands
DEV_URL = http://localhost:3000/wp-content/plugins/your-plugin/frontend
PLUGIN_SLUG = your-plugin
SERVER_VARIABLES = your_plugin_
DEV_SSL = false # https for the dev server
DEV_SSL_CERT_PATH = /path/to/cert.crt
DEV_SSL_KEY_PATH = /path/to/cert.key
DEV_DOMAIN = http://localhost:3000 # Playwright target
WP_USERNAME =
WP_PASSWORD =
.env is for local development. It holds a WordPress username and password for the end-to-end tests, so keep it out of version control — the repository tracks .env.example only.