LogoLogo
  • Planet 4
  • Development
    • Contribute
    • Installation
    • Git Guidelines
    • Coding Standards
    • Continuous Delivery
  • CI/CD
    • Test Instances
    • Deployment
    • Testing
      • End-to-end Tests
      • Visual Regression Tests
  • NRO Customization
    • Development
      • Using Child Themes
      • Package Registry
      • Plugins
    • Testing
      • Visual Regression Tests
    • Deployment
      • Production
      • DB/Media Sync
  • Infrastructure
    • NRO Generation
    • ElasticSearch
    • Cloudflare
  • Recipes
    • Maintenance page
    • Production sync
    • Running commands
  • Platform
    • Practices
    • ADRs
      • [ADR-0001] Use Gitbook for Technical Documentation
      • [ADR-0002] P3 Archive elastic search integration
      • [ADR-0003] WYSIWYG Blocks Architecture
      • [ADR-0004] Switch to Monorepo
      • [ADR-0006] Define scope for deployment environments
      • [ADR-0008] PSR-4 Autoloading Standard
      • [ADR-0009] Include Media Library in master theme
      • [ADR-0011] PHP Coding Standards
      • [ADR-0012] Use custom SCSS syntax for variables
      • [ADR-0013] Choose a ticketing system
      • [ADR-0014] Choose a testing framework
      • [ADR-0015] Use block templates to build block patterns
      • [ADR-0016] Form Builder data retention policy
      • [ADR-0017] Move blocks into the theme
    • Changelog
      • 2024
      • 2023
      • 2022
      • 2021
      • 2020
      • 2019
      • 2018
  • Tech
    • Wordpress
    • Blocks
    • Plugins
    • Hooks
    • Data migrations
    • CSS variables
Powered by GitBook
On this page
  • Considered Options
  • Decision Outcome
  • Pros and Cons of the Options
  • PSR-4
  • Custom Classes
  • Links
Edit on GitHub
  1. Platform
  2. ADRs

[ADR-0008] PSR-4 Autoloading Standard

Implement PSD-4 Autoloading to our two main app repositories (master-theme, plugin-blocks).

Previous[ADR-0006] Define scope for deployment environmentsNext[ADR-0009] Include Media Library in master theme

Last updated 5 months ago

  • Status: accepted

  • Deciders: Engineering Team

Considered Options

  • Adjust all of our application repositories (themes, plugins) to adhere to PSR-4

  • Continue using custom autoloading classes

Decision Outcome

Chosen option: Implement PSD-4 Autoloading to our two main app repositories (master-theme, plugin-blocks).

Pros and Cons of the Options

PSR-4

  • Good, because following widely adopted standards helps new developers understand the code faster +1

  • Good, because we will automatically benefit from optimisations implemented by Composer (see ) +2

  • Good, because dropping the “class-” prefix WordPress dictates makes it easier to navigate folders (both in CLI and IDE)

  • Bad, because it forces us to change file structure/naming

Custom Classes

  • Good because not depends on the composer (external dependency)

  • Good because not restricted for specific filename/class name

  • Bad, because a custom autoloader has a risk of bugs and prefix misuse

Links

composer docs
PSR-4 Autoloading Standard