DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Bootstrapper Module

How it works

The main PHP lines of the module explained in plain English.

PreviousMotivationNextHow to use

Last updated 4 years ago

Was this helpful?

This module is by far the simplest among all of them. But it only works if a couple of things that are fulfilled:

  1. It must be the very first thing that the plugin loads.

  2. The other modules (and the plugin itself) must refuse to continue running if this module fails to initialize.

Luckily, the first condition is pretty simple to fulfill. The module's entry point is the bootstrap.php file (just like all the other modules, actually) and it is defined in as an autoload target. Since every single other module also depends on the Bootstrapper module, Composer's autoloader will ensure this file is the first one to load across the entire framework.

As far as the second condition is concerned, you can rest assured that our other modules to follow it. As for your own plugin, well, that depends on you so we're probably covered again!

On a functional level, the file bootstrap-functions.php contains the checker function. The main logic is handled by the very simple dws_wp_framework_check_php_wp_requirements_met function.

If the minimum requirements are met, the namespaced constant DWS_WP_FRAMEWORK_BOOTSTRAPPER_INIT is set to true, otherwise it is set to false . It is best to not access the constant directly, but through use of the helper function dws_wp_framework_get_bootstrapper_init_status defined .

Should the constant be set to false, the module also outputs as an admin notice. This notice will contain the name of the module that failed to initialize and provide some more information about what went wrong.

If the Bootstrapper module fails, all subsequent framework modules will fail too. However, the admin notice will only be outputted only once and will contain the name of the first module that failed only.

Here is an example of what the notice looks like:

the composer.json file
in bootstrap.php
in bootstrap-functions.php
the requirements-error.php template
Default requirements error admin notice