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. Key concepts and dev tools

Object-Oriented Programming

PreviousPHP and WP requirementsNextSemantic Versioning

Last updated 4 years ago

Was this helpful?

The DWS WP Framework is fully OOP. Support for OOP hasn’t been historically great in PHP, but it’s remarkably good in PHP7 in general and PHP7.4 in particular. And it only gets better in PHP8!

That means that most logic is encapsulated in () classes. There is a long debate to be had about OOP vs non-OOP, but we believe that WordPress plugins are great candidates for an OOP design.

To make things predictable (and standardized), the namespace-structure follows the PSR-4 standard. You can read more about that but it’s basically a convention that enforces the following things:

  • One class -- one PHP file.

  • The namespace structure follows the folder structure of the filesystem.

  • Each namespace is of the form:

\<ProjectNamespace>(\<SubNamespaceNames>)*\<ClassName>

For example, let’s assume that:

  • your project namespace is SomeCompany\Plugins\SomePlugin

  • all your PHP files are in the includes folder

Then the class SomeCompany\Plugins\SomePlugin\Admin\Settings will be in the file includes/Admin/Settings.php.

namespaced
here