Let’s architect our configuration store. We’ll start with identifying what it’s purpose is and why it exists. We’ll look at it from a reusable mindset to ensure that it can accept any configuration, as long as it follows our defined structure. In Part 2, we’ll walk through developing the structure of our API in procedural format.
The intent of our store is:
- Load a configuration file from the filesystem one time only.
- Load the configuration into our store (container) – one time only.
- Retain the configuration in the store such that it’s available in the app to get parameters throughout the entire web page request.
- Get a specific configuration from the store.
- Get a specific parameter from a configuration within the store.
Key concepts to remember as we design it:
- Our store is a container.
- It will have an API to expose the getters and setters.
- It doesn’t care what the specific configuration is, as long as each file has one element where the key is the unique storage key and the value is the configuration.
Prefer to Skip Over the ConfigStore?
If you’d prefer to skip over the construction of the ConfigStore and get back to working just on the meta box module, that’s cool. Here’s what you need to do:
- Click on this link, which takes you to the reusable branch in the repository on GitHub.
- Copy each file into your project.
- In your
bootstrap.phpfile, load the
config-store/module.phpas I did here.
- Then skip over all of the Configuration Store episodes.
Who needs copy/paste? Right. Writing code from scratch is fun!
Total Lab Runtime: 04:38:42
- 1 Lab Introductionfree 13:01
- 2 Add Another Meta Box - Portfoliopro 11:05
- 3 Code Review - Repeating Patternspro 07:17
- 4 The Reusable Mindsetfree 07:52
- 5 Separating Implementation from Business Logicfree 06:31
- 6 Plan It Outpro 06:35
- 7 Laying Out the Architecturepro 08:16
- 8 Configuration Model - Add Parameterspro 11:58
- 9 Configuration Model - Render Parameterspro 10:36
- 10 Configuration Model - Save Parameterspro 07:23
- 11 The Implementation Configurationspro 08:33
- 12 Fix the Config Modelpro 01:53
- 13 Architect the ConfigStore - Part 1pro 07:33
- 14 Architect the ConfigStore - Part 2pro 13:34
- 15 Loading the Configuration into the Storepro 16:04
- 16 Get Configuration or Parameter from the Storepro 12:43
- 17 Wire Meta Box to the ConfigStorepro 13:03
- 18 Merging Configuration with the Defaultspro 10:50
- 19 Get Only the Meta Box Keys From ConfigStorepro 22:29
- 20 Rethink the Save Functionalitypro 07:58
- 21 Is it Okay to Save?pro 05:41
- 22 Remap Custom Fields Config for Savepro 11:54
- 23 Fix the Default Mergepro 18:03
- 24 Walk Through & Test Our Save Functionpro 08:53
- 25 Improving the Renderpro 09:30
- 26 Optimization, Review, & Housekeepingpro 10:13
- 27 Wrap it Upfree 09:14