{"id":16007462,"url":"https://github.com/ama-team/yamligniter","last_synced_at":"2025-04-05T02:15:08.951Z","repository":{"id":56946605,"uuid":"85299312","full_name":"ama-team/yamligniter","owner":"ama-team","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-17T13:27:37.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T10:23:12.547Z","etag":null,"topics":["codeigniter"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ama-team.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-17T10:24:29.000Z","updated_at":"2017-05-20T21:10:03.000Z","dependencies_parsed_at":"2022-08-21T02:30:06.617Z","dependency_job_id":null,"html_url":"https://github.com/ama-team/yamligniter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ama-team%2Fyamligniter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ama-team%2Fyamligniter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ama-team%2Fyamligniter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ama-team%2Fyamligniter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ama-team","download_url":"https://codeload.github.com/ama-team/yamligniter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276188,"owners_count":20912288,"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":["codeigniter"],"created_at":"2024-10-08T12:03:33.856Z","updated_at":"2025-04-05T02:15:08.927Z","avatar_url":"https://github.com/ama-team.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YamlIgniter\n\nThis repository contains a simple tool to boot CodeIgniter projects \nwith YAML config.\n\n## Motivation\n\nThere are two types of configuration: declarative and executed (so it's \nbasically a big function that somehow provides configuration to \napplication, either via return or side-effects). While \nexecuted configuration (which is used by CodeIgniter) gives\ninfinite freedom to end user (you can compute values on-the-fly), it \nlacks the ability of easy machine processing that declarative \nconfiguration has, and limits your freedom in automation. Declarative\nconfiguration, such as YAML files, is static, but can be easily created\nby a script using any language, and gives huge benefit for automating \nthings like continuous deployments and automated environment creation\n(for feature branches, for example).\n\nBecause we had some troubles deploying our CodeIgniter projects from\nscratch, i decided to help CodeIgniter to switch to YAML for \nconfiguration.\n\n## Installation\n\nJust the usual thing:\n\n```\ncomposer require ama-team/yamligniter \n```\n\n## Usage\n\nCodeIgniter takes it's config by letting user to fill some variables\nin user-maintained scripts. Let's exploit that:\n\n```php\n// application/config/config.php\n\nextract(AmaTeam\\YamlIgniter::config(__DIR__ . '/config.yml'));\n```\n\n```php\n// application/config/database.php\n\nextract(AmaTeam\\YamlIgniter::database(__DIR__ . '/database.yml');\n```\n\nYou can now also use environment-based configuration files:\n\n```php\n// application/config/database.php\n\nextract(AmaTeam\\YamlIgniter::database(__DIR__ . '/' . ENVIRONMENT . '/database.yml');\n```\n\nYamlIgniter will take your configuration, fill the missing gaps with \ndefault values, and then return full config to you for future \nprocessing or extraction into local variables.\n  \n## Formals\n\nStatic methods `YamlIgniter::database()` and `YamlIgniter::config()` \nare just wrappers around similar non-static methods: they've been \nimplemented solely for simplified access. Their implementation differ a\nlittle - `::config()` simply reads YAML file, fills all gaps with \ndefault values and returns in an array under `config` key:\n\n```yml\n# config.yml\nbase_url: https://project.dev/\n\n# results in\nconfig:\n  base_url: 'http://project.dev/'\n  index_page: 'index.php'\n  uri_protocol: 'REQUEST_URI'\n  ...\n```\n\nDatabase method acts differently. The source config file should \nrepresent `database.php` structure:\n\n```yml\n# database.yml\nquery_builder: true\ndb:\n  default:\n    username: johnny\n    password: rubber\n    database: project\n    failover:\n      - username: johnny\n        password: rubber\n        database: project\n        hostname: failover-host.intranet\n```\n\nYamlIgniter then takes this input and transforms as described:\n\n- Merges root context with defaults for framework version (in current \nexample, `active_group: default` would be added to config)\n- Iterates over all entries of `db`, merging every entry with default \ndatabase context\n- Iterates over all entries of `db.*.failover`, merging every entry \nwith default database context\n\nSo above example would result in:\n\n```yml\nquery_builder: true\nactive_group: default\ndb:\n  default:\n    dsn: ''\n    hostname: localhost\n    username: johnny\n    password: rubber\n    database: project\n    dbdriver: mysqli\n    ...\n    failover:\n      - dsn: ''\n        username: johnny\n        password: rubber\n        database: project\n        hostname: failover-host.intranet\n        dbdriver: mysqli\n        ...\n```\n\n## Testing\n\nTesting is done via [Codeception][codeception] framework alongside with\n[Allure Framework][allure] for reporting. Launching tests is easy:\n\n```bash\nbin/codecept run\n```\n\nTo get full-blown reporting, install Allure commandline and use \nfollowing command:\n\n```bash\ncomposer run-script test:full\n```\n\n## Contributing\n\nFork, fix, enhance, create pull request, ping maintainers if there's no\nreaction.\n\n## Self-esteem badge cellar\n\n### Master branch\n\n[![CircleCI/master](https://img.shields.io/circleci/project/github/ama-team/yamligniter/master.svg?style=flat-square)](https://circleci.com/gh/ama-team/yamligniter/tree/master)\n[![Coveralls/master](https://img.shields.io/coveralls/ama-team/yamligniter/master.svg?style=flat-square)](https://coveralls.io/github/ama-team/yamligniter?branch=master)\n[![CodeClimate](https://img.shields.io/codeclimate/github/ama-team/yamligniter.svg?style=flat-square)](https://codeclimate.com/github/ama-team/yamligniter)\n[![Packagist](https://img.shields.io/packagist/l/ama-team/yamligniter.svg?style=flat-square)](https://packagist.org/packages/ama-team/yamligniter)\n[![Packagist](https://img.shields.io/packagist/v/ama-team/yamligniter.svg?style=flat-square)](https://packagist.org/packages/ama-team/yamligniter)\n\n### Dev branch\n\n[![CircleCI/dev](https://img.shields.io/circleci/project/github/ama-team/yamligniter/dev.svg?style=flat-square)](https://circleci.com/gh/ama-team/yamligniter/tree/dev)\n[![Coveralls/dev](https://img.shields.io/coveralls/ama-team/yamligniter/dev.svg?style=flat-square)](https://coveralls.io/github/ama-team/yamligniter?branch=dev)\n\n  [allure]: http://allure.qatools.ru/\n  [codeception]: http://codeception.com/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fama-team%2Fyamligniter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fama-team%2Fyamligniter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fama-team%2Fyamligniter/lists"}