{"id":14987396,"url":"https://github.com/tattersoftware/codeigniter4-settings","last_synced_at":"2025-04-12T00:03:26.222Z","repository":{"id":34545012,"uuid":"180051076","full_name":"tattersoftware/codeigniter4-settings","owner":"tattersoftware","description":"Lightweight settings manager for CodeIgniter 4","archived":false,"fork":false,"pushed_at":"2024-01-18T14:14:09.000Z","size":128,"stargazers_count":22,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2024-10-01T00:41:34.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tattersoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T02:03:33.000Z","updated_at":"2023-12-21T10:39:46.000Z","dependencies_parsed_at":"2024-06-21T07:25:18.551Z","dependency_job_id":null,"html_url":"https://github.com/tattersoftware/codeigniter4-settings","commit_stats":{"total_commits":55,"total_committers":3,"mean_commits":"18.333333333333332","dds":0.2727272727272727,"last_synced_commit":"d6cf7eff7a158f7c9975fd13a34756c17e400fdf"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tattersoftware","download_url":"https://codeload.github.com/tattersoftware/codeigniter4-settings/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219850285,"owners_count":16556321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T14:14:33.189Z","updated_at":"2024-10-14T00:20:51.947Z","avatar_url":"https://github.com/tattersoftware.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tatter\\Settings\nLightweight settings management for CodeIgniter 4\n\n[![](https://github.com/tattersoftware/codeigniter4-settings/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-settings/actions/workflows/test.yml)\n[![](https://github.com/tattersoftware/codeigniter4-settings/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-settings/actions/workflows/analyze.yml)\n[![](https://github.com/tattersoftware/codeigniter4-settings/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-settings/actions/workflows/inspect.yml)\n[![Coverage Status](https://coveralls.io/repos/github/tattersoftware/codeigniter4-settings/badge.svg?branch=develop)](https://coveralls.io/github/tattersoftware/codeigniter4-settings?branch=develop)\n\n## WARNING\n\nSince this library's last major version the CodeIgniter team has published its own\n[Settings Library](https://github.com/codeigniter4/settings). That library and this offer\nsome non-overlapping features but they do represent a conflict in name and implementation.\nThe future of this library is not yet determined, but some options are:\n* Deprecate this library and move any missing features to the CodeIgniter version\n* Rework this library as an extension of the official package\n* Maintain the current functionality with a name change to avoid conflict\n\nTo follow or contribute to the planning for this library please visit the\n[Upcoming Changes Discussion](https://github.com/tattersoftware/codeigniter4-settings/discussions/31).\n\n## Quick Start\n\n1. Install with Composer: `\u003e composer require tatter/settings`\n2. Update the database: `\u003e php spark migrate -all`\n3. Use `spark` to create templates: `\u003e php spark settings:add timezone user America/New_York`\n4. Use the service to access user settings:\n```\nservice('settings')-\u003etimezone = $_POST['timezone_preference'];\n...\n$userTimezone = service('settings')-\u003etimezone;\n```\n\n## Features\n\nProvides ready-to-use settings management for CodeIgniter 4\n\n## Installation\n\nInstall easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities\nand always be up-to-date:\n* `\u003e composer require tatter/settings`\n\nOr, install manually by downloading the source files and adding the directory to\n`app/Config/Autoload.php`.\n\nOnce the files are downloaded and included in the autoload, run any library migrations\nto ensure the database is setup correctly:\n* `\u003e php spark migrate -all`\n\n## Usage\n\nOnce the library is included all the resources are ready to go and you are ready to start\nadding settings. You may import setting templates directly into the `settings` table or\nadd them manually with the CLI command `php spark settings:add`.\n\n**Settings** also comes with a database seeder for some recommended default templates. Run\nthe seeder from the command line:\n\t\n\tphp spark db:seed \"Tatter\\Settings\\Database\\Seeds\\SettingsSeeder\"\n\nThis will add appropriately-scoped templates and default values for the following settings:\n\n| Name             | Description                                     | Data Type | Default Value                   | Protected |\n| ---------------- | ----------------------------------------------- | --------- | ------------------------------- | --------- |\n| siteVersion      | Current version of this project                 | string    | 1.0.0                           | Yes       |\n| brandName        | Brand name for this project                     | string    | Brand                           | Yes       |\n| brandLogo        | Brand logo for this project                     | string    | /assets/images/logo.png         | Yes       |\n| orgName          | Your organization name                          | string    | Organization                    | Yes       |\n| orgLogo          | Your organization logo                          | string    | /assets/images/logo.png         | Yes       |\n| orgUrl           | Your organization URL                           | uri       | https://example.com             | Yes       |\n| orgAddress       | Your organization address                       | string    | 4141 Postmark Dr  Anchorage, AK | Yes       |\n| orgPhone         | Your organization phone                         | string    | (951) 262-3062                  | Yes       |\n| currencyUnit     | Currency format for number helper               | string    | USD                             | Yes       |\n| currencyScale    | Conversion rate to the fractional monetary unit | int       | 100                             | Yes       |\n| databaseTimezone | Timezone for the database server(s              | string    | UTC                             | Yes       |\n| serverTimezone   | Timezone for the web server(s)                  | string    | UTC                             | Yes       |\n| timezone         | Timezone for the user                           | string    | America/New_York                | No        |\n| theme            | Site display theme                              | int       | 1                               | No        |\n| perPage          | Number of items to show per page                | int       | 10                              | No        |\n\n*Warning: This list is subject to change between major versions.*\n\nNote that the seeder will not overwrite existing values so it is safe to re-run at any time.\nSee also [src/Database/Seeds/SettingsSeeder.php](src/Database/Seeds/SettingsSeeder.php).\n\n### Setting Scope\n\n``Settings`` come in three modes: global, user, and dynamic.\n* Global settings are the same for every user and provide project owners to set application-wide values; set `protected` to `1`\n* User settings start with a template value but each user may make their own value that persists across sessions; set `protected` to `0`\n* Dynamic settings have no template but can be created and returned on-the-fly; they only persists for the current session.\n\nExamples:\n\n| Name          | Scope   | Content          | Notes                                        | Protected? |\n|-------------- | ------- | ---------------- | -------------------------------------------- | ---------- |\n| latestRelease | Global  | 0.7.6            | Git-style tag of latest code release         | 1          |\n| timezone      | User    | America/New_York | Local timezone to use across the application | 0          |\n| perPage       | User    | 10               | Default number of items to show per page     | 0          |\n| jobsSearch    | Dynamic | backend php      | User's most recent search term for jobs      | n/a        |\n\n\n* When you release a new version of your software:\n\n\tmodel('SettingModel')-\u003ewhere('name', 'latestRelease')-\u003eupdate(['content' =\u003e '1.2.3');\n\techo view('home', ['latestRelease' =\u003e service('settings')-\u003elatestRelease]);\n\n* When a user searches a list of jobs:\n\n\t$settings-\u003ejobsSearch = $_POST['searchTerm'];\n\t$data['jobs'] = $jobModel-\u003epaginate($settings-\u003eperPage);\n\n### Magic Config\n\n``Settings`` comes with a magic configuration file that allows direct access to template values. This is a convenient\nway to access the library in a traditional framework fashion:\n\n\t$logo = config('Settings')-\u003eprojectLogo;\n\nNote that unlike the Service or Library values from the magic config are directly from the template default and are not\naffected by user overrides:\n\n\tservice('settings')-\u003eset('perPage', 20);\n\n\techo service('settings')-\u003eperPage; // 20\n\techo config('Settings')-\u003eperPage; // 10\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattersoftware%2Fcodeigniter4-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-settings/lists"}