Your first plugin
As mentioned on the modular design page, using our framework usually makes sense when you use at least the first 3 modules (Bootstrapper, Helpers, and Foundations). Those are as general as we can humanly think of and they try to set literally no expectations on your project while simultaneously offering you all the abstractions you need (in the form of Interfaces, Traits, and Abstract Classes) to build your plugin the way you see fit.
If you only use only these 3 modules, there is a good chance there will be some unused files, but that shouldn't have any performance impact if you use the Composer autoloader (which for the rest of this documentation, we will definitely assume that you are).
If you haven't already, check out our dedicated section for setting up a development environment on your machine.
There is an example plugin on GitHub that only uses the first 5 modules. It's meant as a sort-of starter project for adding custom code to client websites (basically a replacement for the classical functions.php), but it can be easily used as a starter plugin as well.
We recommend that you download this plugin and use it as your starting base. This is a checklist of things you probably want to do after downloading the example plugin:
  1. 1.
    Rename the folder from wordpress-plugins-utility to the slug of your plugin.
  2. 2.
    Do a search for DWS WordPress Utility Plugin and replace it with your plugin's name.
  3. 3.
    Similarly, make sure to update the plugin header in bootstrap.php and README.md and optionally change the minimum PHP and WP versions.
  4. 4.
    Change the Deep Web Solutions references in composer.json and package.json.
  5. 5.
    Update the composer.json file to reflect the modules you really want to use. By default, the example plugin also installs php-di/php-di for dependency injection and monolog/monolog for logging but you are free to use your preferred packages.
  6. 6.
    Do a search for DWS_Deps and replace it with a unique name for your plugin. For example, we're using DWS_LPM_Deps for our Locked Payment Methods plugin.
  7. 7.
    Run composer update --ignore-platform-reqs and npm update in the plugin directory.
Congratulations! You are now ready to use start building a WordPress plugin using the DWS Framework. Continue reading the documentation of each module in order to understand how to use the framework effectively.
Copy link