Create the Basic Plugin Structure

The most simple plugin has only one folder and one file. Both must have the same name. So the basic file structure for our plugin looks like this:

/cookieconsent // plugin-folder
- cookieconsent.php // plugin-file

The cookieconsent.php contains the main logic and central entry point of our plugin. But we need some more files. Let us describe again, what our plugin should do:

If we simply follow this description, then the file structure of our cookie consent plugin looks like this:

  - cookieconsent.php
  - cookieconsent.yaml
     - cookieconsent.twig
     - cookieconsent.min.js
     - cookieconsent.min.css

As you can see, a clear description of the plugin's functionality is the key. Coding is so much easier if everything is described in clear words.

Let us check the naming conventions again:

The names and the structure of all other files and folders are a matter of taste and completely up to you.

Next Step: The Configuration File

We have a structure now, so let's start with a basic configuration file before we write our first php-code for our plugin.