Plugin Directory Structure

Using the code editor of your preference, navigate to the Plugins folder and create a new folder domain-core. The domain-core folder will contain all our plugin files.

domain-core folder

We will create the following files and folder at the root level of the plugin folder.

  • The core directory/folder
  • composer.json file
  • domain-core.php – the main plugin file.
Plugin folder structure
domain-core File Structure

You need to start with these files at the plugin’s root level directory. We will discuss the folder and file contents in the next topic. First, let’s go into the core directory and add more files and directories we will use in our plugin.

core folder

Inside the core folder, we need to create the following;

  • Admin folder/directory
  • Base folder/directory
  • Init.php file
core plugin folder structure
core folder structure

Base folder

The create the following files inside the Base folder.

  • BaseController.php
  • Activate.php
  • Deactivate.php
Plugin Base folder structure
Contents of the Base folder

Admin folder

In the Admin folder, -we will create the ReusableBlock.php. This is where we will be adding the reusable block functionality for them to appear on the Admin menu.

  • ReusableBlock.php
Admin directory
The ReusableBlock.php file inside the Admin folder


The plugin Github repo has some files and folders that we have not created in the steps above. We will look at how these are created in the following topics.

Overall file structure

At the end of this topic, your file structure should look like this.

Standard plugin directory structure
The standard plugin directory structure


You must have noticed that all our file names and folders inside the “core” directory have names starting with capital letters. This is one of the requirements when using PSR-4. Thus, you should follow this standard.