{"id":22748824,"url":"https://github.com/apinstein/config-magic","last_synced_at":"2026-03-04T08:32:03.293Z","repository":{"id":62486306,"uuid":"256278","full_name":"apinstein/config-magic","owner":"apinstein","description":"Configuration file manager for php projects. Easily manage multiple downstream config files across multiple machines in an organized way.","archived":false,"fork":false,"pushed_at":"2018-11-01T19:55:16.000Z","size":26,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T19:59:23.901Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/apinstein.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2009-07-21T00:49:03.000Z","updated_at":"2018-11-01T19:55:18.000Z","dependencies_parsed_at":"2022-11-02T10:02:31.692Z","dependency_job_id":null,"html_url":"https://github.com/apinstein/config-magic","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/apinstein/config-magic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apinstein%2Fconfig-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apinstein%2Fconfig-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apinstein%2Fconfig-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apinstein%2Fconfig-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apinstein","download_url":"https://codeload.github.com/apinstein/config-magic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apinstein%2Fconfig-magic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30076868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T08:01:56.766Z","status":"ssl_error","status_checked_at":"2026-03-04T08:00:42.919Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-12-11T03:35:40.419Z","updated_at":"2026-03-04T08:32:03.275Z","avatar_url":"https://github.com/apinstein.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"ConfigMagic\n===========\n\nA simple organizational tool to help you manage config files for your web app.\n\nINSTALLATION\n------------\n\n```sh\n$ composer global require apinstein/config_magic\n```\n\nHOW IT WORKS\n------------\n\nA typical web app has 1 or more config files. For instance, your app might have the following files:\nhttpd.conf      (apache config)\nwebapp.conf     (framework config)\nsh.conf         (shell script config)\n\nA typical web app is also run on more than one server. For instance:\ndev-alan\ndev-jason\nstaging\nproduction\n\nConfiguring your web app to run on a new envirionment can quickly become a painful process as you have to remember to edit multiple files with correct information.\nIn my experience, a lot of time is wasted trying to:\n    - Bootstrap the new environment one config file at a time\n    - Remember all of the different places and values that need to be configued\n    - Messing with regex replacements to try to batch-replace things listed repetitively\n\nConfigMagic solves these problems by letting you quickly and easily set up template files for each config file.\nYour template file can contain default data for each variable substitution used by your configs.\nYou then need only set up a profile.ini for each machine profile and declare any non-default data you need to use.\nConfigMagic then writes out all config files for a given profile.\n\nConfigMagic comes with a command-line utility \"cfg\" that lets you quickly manage this process.\n\nEXAMPLE\n-------\n\nInitialize ConfigMagic for this project.\n\n```sh\n$ cfg -i\n```\n\nSet up an example config file\n\n```sh\n$ echo \"myProfile = ##PROFILE##\" \u003e config/templates/example.conf\n$ echo \"myVar = ##my.var##\" \u003e\u003e config/templates/example.conf\n```\n\nSet up an empty profile\n\n```sh\n$ echo \"my.var = 10\" \u003e config/profiles/dev.ini\n```\n\nBuild all config files for the \"dev\" profile\n\n```sh\n$ cfg dev\n```\n\nCheck\n\n```sh\n$ cat config/example.conf\n```\n\nOutput:\n```\nmyProfile = dev\nmyVar = 10\n```\n\nVARIABLE SUBSTITUION\n--------------------\n\nVariables in the template files take the form of:\n\n`##my.var##`\n\nAnd will be replace by the corresponding ini file variable:\n\n`my.var`\n\nVariables in the profile.ini file override the default values set in the config.ini file.\n\nVariables can also use variable substituion on variables previously defined (ie higher in the file).\n\na = foo\nb = ##a##-bar       # b = foo-bar\n\nThe following additional variables are automatically defined:\n\n`##CONFIG##`          =\u003e the current config name\n`##PROFILE##`         =\u003e the current profile name\n`##CONFIG_DIR##`      =\u003e the absolute path to the config dir\n`##OUTPUT_DIR##`      =\u003e the absolute path to the output dir\n`##TEMPLATES_DIR##`   =\u003e the absolute path to the config/templates dir\n\nAny variable substitution in the template file that isn't defined in any ini file will be skipped and a warning will print out.\n\nDYNAMIC TEMPLATES\n-----------------\n\nAll templates are treated as PHP code, which means that you can use normal PHP syntax to dynamically generate config files based on profile data.\n\nAll variables available in normal variable substition (in form of ##varname##) are available in the template, via the $profileData variable. For instance:\n\n```php\n\u003c?php if (!$profileData['##isProduction##']): ?\u003e\n'classname' =\u003e 'DebugPDO',\n\u003c?php endif; ?\u003e\n```\n\nNOTE: if you are actually generating a php file, you will need to escape php tags so that they are not seen as a \"PHP Start Tag\":\n\nlong php tags\n`\u003c\u003c?php ?\u003e?php`\n\nshort php tags\n`\u003c\u003c? ?\u003e?`\n\nDYNAMIC VARIABLES\n-----------------\n\nIn some cases you may want to programmatically munge the profile data directly rather than in the template files via dynamic templates.\n\nA good example of this is to call realpath() on a path at the variable level so you don't have to remember to do this in each template.\n\nThis can be done with this simple syntax:\n\n```\nproject.dir = \"\u003c?php realpath('##OUTPUT_DIR##/..') ?\u003e\"\n```\n\nThe php processing will occur *after* the variable substitution has processed.\n\nCONCLUSION\n----------\n\nGetting started with ConfigMagic is very easy and provides a solid organizational framework to manage your config files. I hope you enjoy it.\n\nPlease feel free to send comments or suggestions my way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapinstein%2Fconfig-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapinstein%2Fconfig-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapinstein%2Fconfig-magic/lists"}