Configuration

This guide covers the configuration options in the scaffold.

config/app.php

The main application configuration file:

return [
    /**
     * Application name.
     */
    'name' => 'My Plugin',

    /**
     * Debug mode.
     * Inherits from WordPress WP_DEBUG constant.
     */
    'debug' => defined('WP_DEBUG') && WP_DEBUG,

    /**
     * Service providers to register.
     * Add your custom providers here.
     */
    'providers' => [
        // \MyPlugin\Providers\AppServiceProvider::class,
    ],

    /**
     * Settings page capability.
     * Users need this capability to access plugin settings.
     */
    'capability' => 'manage_options',
];

Configuration Options

name

The display name for your plugin. Used in admin pages and notifications.

'name' => 'Task Manager',

debug

Enable or disable debug mode. When enabled:

  • More verbose error messages
  • Additional logging
  • Dev-only features
'debug' => true, // Always debug
'debug' => false, // Never debug
'debug' => defined('WP_DEBUG') && WP_DEBUG, // Follow WordPress

providers

Array of service provider classes to register. Providers are registered after framework providers.

'providers' => [
    \MyPlugin\Providers\AppServiceProvider::class,
    \MyPlugin\Providers\AdminServiceProvider::class,
    \MyPlugin\Providers\ApiServiceProvider::class,
],

capability

WordPress capability required to access plugin settings.

'capability' => 'manage_options', // Administrators only
'capability' => 'edit_posts',     // Editors and above
'capability' => 'read',           // All logged-in users

PluginContext Configuration

The PluginContext is configured in the main plugin file:

$context = PluginContext::create([
    'file'       => __FILE__,       // Required: Main plugin file
    'slug'       => 'my-plugin',    // Required: Plugin slug
    'prefix'     => 'myplugin_',    // Required: Database prefix
    'textDomain' => 'my-plugin',    // Required: Text domain
    'version'    => '1.0.0',        // Required: Version string
]);

All five parameters are required. Missing any will throw an InvalidArgumentException.

Environment Variables

You can use environment variables for sensitive configuration. Create a .env file in your plugin root:

MY_PLUGIN_API_KEY=your-api-key
MY_PLUGIN_DEBUG=true

Access in code:

$apiKey = getenv('MY_PLUGIN_API_KEY');

Note: Add .env to your .gitignore to prevent committing secrets.

Database Configuration

Database tables are created using migrations. Table names are automatically prefixed using the PluginContext:

// In a migration
$table = $this->context->tableName('orders');
// Returns: wp_myplugin_orders

Activation Options

Default options set during activation (in app/Lifecycle/Activator.php):

// Version tracking for migrations
update_option($context->optionKey('version'), $context->version());

// Keep data on uninstall (default: true)
update_option($context->optionKey('keep_data_on_uninstall'), true);

Next Steps