CodeIgniter Forums

Full Version: Settings Management Library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all! I'd like to share my final CodeIgniter 3 library, fully rewritten for CI4 and ready to use. As with all my libraries, it's "configuration lite" so read the docs at GitHub, plug it in, and go.

Tatter/Settings - plug-and-play settings management for CodeIgniter 4

Basic usage:
1. Install with Composer: `> composer require tatter/settings`

2. Update the database: `> php spark migrate:latest -all`
3. Add settings: `> php spark settings:add timezone user America/New_York`
4. Load the service: `$settings = service('settings');`
5. Get/set settings per user:
PHP Code:
$settings->timezone $_POST['timezone_preference'];
$userTimezone $settings->timezone

Once the library is included all the resources are ready to go and you are ready to start adding settings. You may import setting templates directly into the `settings` table or add them manually with the provided CLI command: `> php spark settings:add`

Settings take one of three scopes: session, user, global.
  • Global settings are the same for every user and provide a dynamic way to set application-wide values
  • User settings start with a default template value but each user may make their own default that persists across sessions
  • Session settings start with a default template value and may be changed by a user but revert for each new session

In addition to the five libraries I have ported (and the original 'Audits') I have two CI3 libraries I never completed: 'Notices' (a user communication gateway) and 'Plots' (a sitemap generator and route analyzer). Please let me know if you'd find interest in these for CI4.
As always I am eager for feedback, suggestions, and contributions - feel free to respond here or on GitHub ( Thanks for reading!

Thanks for reading!
Hey MGatner!

Great work!

I'd recommend adding some tests to your libraries though. Many people will hesitate to add untested code to their application.
Thanks for the feedback and suggestion! I’ve never used PHPUnit but with its core involvement in CI4 testing it’s been on my list. I’ll dive in and plan to add the to my libraries. I’m open to any pointers, resources, ideas if you have them!
I'm a big fan of codeception which is built on top of PHP unit. You should take a look as well.
Thanks! I’ll take a look.
@MGatner you might want to take a look at this and follow these practices when releasing a new package
Thanks! I’ll take a look. I love The League’s stuff.