Setting up the WordPress Development Environment
Master professional WordPress development by setting up your local environment, initializing the plugin structure, and verifying your first activation.
Welcome to the "Intermediate WordPress Plugins: REST API & React Admin" course. This series assumes you have a baseline understanding of PHP and the WordPress plugin lifecycle, but we are moving beyond simple function files into modern, scalable architecture.
In this lesson, we will establish the foundation for our project: the "Knowledge Base" plugin. We’ll focus on professionalizing your local setup using LocalWP and defining a robust directory structure that supports the build tools we'll introduce in upcoming lessons.
Setting Up Your Local Development Server
To build modern, performant plugins, you need an environment that mimics production while allowing for rapid iteration. While tools like Docker or VVV are popular, LocalWP offers the best balance of speed and ease of use for WordPress plugin development.
- Download and Install: Grab the latest version from the official site.
- Create a New Site: Use the "Preferred" environment settings (latest PHP and MySQL versions).
- Enable WP_DEBUG: This is non-negotiable. Navigate to your site's folder, open
wp-config.php, and ensure the following constants are set:
Logging errors toPHPdefine( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );wp-content/debug.logis far more professional than cluttering your UI with notices. If you find yourself struggling with complex issues later, refer to our guide on Error Handling and Logging: Building Robust WordPress Plugins for best practices.
Initializing the Plugin Structure
A professional plugin isn't just a single file. As we advance through this course, we will integrate React components, REST API classes, and build scripts. A flat structure will quickly become a maintenance nightmare.
Navigate to your site's wp-content/plugins/ directory and create a new folder named knowledge-base. Inside, we’ll start with this structure:
TEXTknowledge-base/ ├── assets/ # Compiled JS/CSS ├── src/ # Source code (React/JS) ├── includes/ # PHP classes and logic ├── knowledge-base.php # Main plugin entry point └── package.json # Dependency management
The Plugin Entry Point
Create knowledge-base.php in the root of your folder. WordPress requires specific headers to recognize your code as a plugin.
PHP<?php #6A9955">/** * Plugin Name: Knowledge Base * Description: A professional knowledge base with REST API and React UI. * Version: 1.0.0 * Author: Your Name * Text Domain: knowledge-base */ if ( ! defined( 'ABSPATH' ) ) { exit; #6A9955">// Exit if accessed directly } #6A9955">// Simple autoloader or inclusion logic goes here later
Verifying Plugin Activation
Once the file is created, navigate to your WordPress Admin dashboard. Go to Plugins > Installed Plugins. You should see "Knowledge Base" listed. Click Activate.
If the plugin activates without error, you have successfully initialized your environment. If you receive a "Plugin file does not exist" error, double-check that your directory name matches the folder containing the main plugin file exactly.
Hands-on Exercise
- Initialize the folder: Create the
knowledge-basedirectory structure as outlined above. - Add a log test: In your
knowledge-base.phpfile, adderror_log('Knowledge Base initialized');inside a simple activation hook. - Verify: Activate the plugin, then check
wp-content/debug.login your local site folder. You should see your message.
Common Pitfalls
- Case Sensitivity: WordPress is case-sensitive regarding folder names on Linux servers. Always use lowercase and hyphens for directory names to avoid deployment issues later.
- Permissions: If you are using a local environment on macOS or Linux, ensure your user has write access to the
wp-content/pluginsfolder. - Ignoring
wp-config: Developing withoutWP_DEBUGenabled is the single biggest mistake beginners make. It hides critical warnings that will eventually break your production site.
As we move forward, keep your directory clean. We will be leveraging Advanced MVC: Dependency Injection for WordPress Plugins later in the course to keep our includes/ folder from becoming a procedural mess.
Recap
In this lesson, we configured a stable LocalWP instance, created a clean directory structure, and verified our plugin's activation. This structure is the bedrock for the build tools we will implement next.
Up next: Introduction to @wordpress/scripts — we'll set up your package.json and start compiling JavaScript.
Work with me

Custom WordPress Plugin Development
Custom WordPress & WooCommerce plugins built to standard — by the developer behind a plugin with 5,000+ active installs and a SaaS with 10,000+ users.

WooCommerce Store Setup & Customization
A WooCommerce store that's set up right, customized to your brand, and ready to sell — by a developer who builds WooCommerce products, not just stores.