CodeIgniter Forums
Settings Management Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forum-34.html)
+--- Thread: Settings Management Library (/thread-73293.html)



Settings Management Library - MGatner - 04-08-2019

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 (https://github.com/tattersoftware/codeigniter4-settings). Thanks for reading!

Thanks for reading!


RE: Settings Management Library - albertleao - 04-08-2019

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.


RE: Settings Management Library - MGatner - 04-08-2019

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!


RE: Settings Management Library - albertleao - 04-08-2019

I'm a big fan of codeception which is built on top of PHP unit. You should take a look as well.


RE: Settings Management Library - MGatner - 04-08-2019

Thanks! I’ll take a look.


RE: Settings Management Library - albertleao - 04-13-2019

@MGatner you might want to take a look at this and follow these practices when releasing a new package

https://github.com/thephpleague/skeleton


RE: Settings Management Library - MGatner - 04-14-2019

Thanks! I’ll take a look. I love The League’s stuff.