{"id":14954923,"url":"https://github.com/studio24/wordpress-multi-env-config","last_synced_at":"2025-04-11T11:45:47.935Z","repository":{"id":13298434,"uuid":"15984545","full_name":"studio24/wordpress-multi-env-config","owner":"studio24","description":"WordPress multi-environment config","archived":false,"fork":false,"pushed_at":"2025-03-24T21:41:28.000Z","size":78,"stargazers_count":787,"open_issues_count":3,"forks_count":97,"subscribers_count":56,"default_branch":"main","last_synced_at":"2025-04-04T04:09:44.598Z","etag":null,"topics":["config","php","wordpress","wp-cli"],"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/studio24.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null}},"created_at":"2014-01-16T23:35:22.000Z","updated_at":"2025-03-24T21:41:32.000Z","dependencies_parsed_at":"2023-01-11T18:33:31.174Z","dependency_job_id":null,"html_url":"https://github.com/studio24/wordpress-multi-env-config","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fwordpress-multi-env-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fwordpress-multi-env-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fwordpress-multi-env-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fwordpress-multi-env-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/studio24","download_url":"https://codeload.github.com/studio24/wordpress-multi-env-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248387952,"owners_count":21095307,"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":["config","php","wordpress","wp-cli"],"created_at":"2024-09-24T13:10:14.715Z","updated_at":"2025-04-11T11:45:47.914Z","avatar_url":"https://github.com/studio24.png","language":"PHP","readme":"# Studio 24 WordPress Multi-Environment Config\n\nThis repository contains Studio 24's standard config setup for WordPress, which \nloads different config based on current environment. This allows you to have different\nsite configuration (e.g. debug mode) for different environments (e.g. production and staging).\n\nCredit is due to FocusLabs [EE Master Config](https://github.com/focuslabllc/ee-master-config)\nwho gave me the inspiration for the organisation of the config files.\n\nPlease note the current version is v2, if you need to use the older v1 version [please see the v1 release](https://github.com/studio24/wordpress-multi-env-config/releases/tag/v1.0.2).\n\n## Contributing\n\nWordPress Multi-Environment Config is an Open Source project. Find out more about how to [contribute](CONTRIBUTING.md).\n\n## Security Issues\n\nIf you discover a security vulnerability within WordPress Multi-Environment Config, please follow our [disclosure procedure](SECURITY.md).\n\n## How it works\n\nThe system detects what environment the current website is in and loads the relevant config file for that environment. \n\nBy default the environment is defined by the hostname, though you can also set this as an environment variable.\n\nConfig files are then loaded according to the current environment. There is support for loading a local config file\nfor sensitive data, which is intended to not be committed to version control.\n\n### Config files\n \nUp to three different config files are loaded:\n\n1. **Default configuration** (in `wp-config.default.php`, e.g. shared settings such as `$table_prefix`)\n2. **Environment configuration** (in `wp-config.{ENVIRONMENT}.php`, e.g. any setting specific to the environment such as database name or debug mode)\n3. **Optional local settings** (in `wp-config.local.php`, e.g. any sensitive settings you do not want to commit to version control, e.g. database password)\n\n### Environment values\n\nBy default, environment values are:\n\n* `production` (live website)\n* `staging` (test website for client review)\n* `development` (local development copy of the website)\n\nYou can add other environment values by adding these to the `wp-config.env.php` file.\n\n## Setting the environment\n\nThe current environment is detected in one of three ways:\n\n### Environment variable\n\nYou can set an environment variable called `WP_ENV` to set which environment the website uses in your webserver configuration. \n\nThis is commonly done via Apache in your virtual host declaration:\n\n    SetEnv WP_ENV production\n    \nIf you don't use Apache consult your webserver documentation.\n\n### Server hostname\n\nThe current environment can also be detected from matching the hostname with the domain setup in `wp-config.env.php`.\n\n### WP-CLI\nIf you're using [WP-CLI](http://wp-cli.org/) you can specify your environment using an '.env' file.\n\nYou need to create a file called `.env` and simply write the current environment in this file as a string.\n\nExample:\n\n```\ndevelopment\n```\nThis file needs to be placed among the wp-config.*.php files (this applies if you keep these files in a sub-folder and the wp-config.php file in the web root).\n\nIt is recommended you do not add this file to version control.\n\n## The wp-config.env.php file\n\nYou need to edit the `wp-config.env.php` file to define some settings related to the current environment URL. This needs to \nbe set regardless of which method is used to set the environment, since all methods set the WordPress URL via settings \ncontained in this file. \n \nThis file contains a simple array, made up of:\n \n```\nenvironment names =\u003e\n    domain  =\u003e The domain name.\n               This can also be an array of multiple domains.\n               You can also use a wildcard * to indicate all sub-domains at a domain, which is useful when using\n               WordPress Multisite. If you use wildcards, set the domain should to a single string, not an array.\n    path    =\u003e If WordPress is installed to a sub-folder set it here.\n    ssl     =\u003e Whether SSL should be used on this domain. If set, this also sets FORCE_SSL_ADMIN to true.\n```\n\nExample usage:\n\n```\n$env = [\n    'production'  =\u003e [\n        'domain' =\u003e 'domain.com',\n        'path'   =\u003e '',\n        'ssl'    =\u003e false,\n    ],\n    'staging'     =\u003e [\n        'domain' =\u003e 'staging.domain.com',\n        'path'   =\u003e '',\n        'ssl'    =\u003e false,\n    ],\n    'development' =\u003e [\n        'domain' =\u003e 'domain.local',\n        'path'   =\u003e '',\n        'ssl'    =\u003e false,\n    ],\n];\n```\n\nIf you use localhost for your local test website, just set the development hostname case to `localhost` rather than `domain.local`.\n\nExample usage when setting a sub-folder, and also serving the live site via SSL:\n\n```\n    'production'  =\u003e [\n        'domain' =\u003e 'domain.com',\n        'path'   =\u003e 'blog',\n        'ssl'    =\u003e true,\n    ],\n```\n\nExample usage for using more than one domain for an environment. \n\n```\n    'production'  =\u003e [\n        'domain' =\u003e ['domain.com', 'domain2.com'],\n        'path'   =\u003e '',\n        'ssl'    =\u003e false,\n    ],\n```\n\nExample usage when using a wildcard for WordPress multi-site.\n\n```\n    'production'  =\u003e [\n        'domain' =\u003e '*.domain.com',\n        'path'   =\u003e '',\n        'ssl'    =\u003e false,\n    ],\n```\n\n## Installing\n\nPlease note this requires PHP5.4 or above. You should really be on PHP5.6 at a minimum!\n\n1. Download the required files via [wordpress-multi-env-config.zip](https://github.com/studio24/wordpress-multi-env-config/releases/latest/download/wordpress-multi-env-config.zip)\n2. First make a backup of your existing `wp-config.php` file.\n3. Copy the following files from this repository to your WordPress installation:\n\n```\nwp-config.default.php\nwp-config.env.php\nwp-config.php\nwp-config.load.php\n```\n        \n3. Set the correct environments you wish to support via the file `wp-config.env.php`, see the documentation above.\n4. Create one `wp-config.{environment}.php` file for each environment. You can use the sample files provided in this repository:\n\n```\nwp-config.development.php\nwp-config.production.php\nwp-config.staging.php\nwp-config.local.php\n```\n\n5. Review your backup `wp-config.php` file and copy config settings to either the default config file or the environment config files as appropriate. It is suggested to:\n    * If the setting is the same across all environments, add to `wp-config.default.php`\n    * If the setting is unique to one environment, add to `wp-config.{environment}.php`\n    * If the setting is sensitive (e.g. database password) add to `wp-config.local.php`\n6. Remember to update the authentication unique keys and salts in `wp-config.default.php`\n7. If you use version control exclude `wp-config.local.php`, an example below for Git:\n\n```\n# .gitignore\nwp-config.local.php\n```\n\nYou should now be able to load up the website in each different environment and everything should work just fine! It should now be safe to delete your backup *wp-config.php* file.\n\n## Moving your config files outside of the document root\n\nIf you want to store your config files outside of the document root for additional security, this is very easy. \n\nSimply move all the config files except for `wp-config.php` itself into another folder (which can be outside the doc root). \nNext amend the require path for `wp-config.load.php` in `wp-config.php` to point to the new location and everything will work just fine! \n\nExample directory structure:\n\n```\nconfig/\n       wp-config.default.php   (Config folder outside of doc root)\n       wp-config.development.php\n       wp-config.env.php\n       wp-config.load.php\n       wp-config.local.php\n       wp-config.production.php\n       wp-config.staging.php\nweb/\n    wp-config.php              (Your website doc root, where WordPress is installed) \n```\n \nExample `wp-config.php`\n\n```\n/** Load the Studio 24 WordPress Multi-Environment Config. */\nrequire_once(ABSPATH . '../config/wp-config.load.php');\n```","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudio24%2Fwordpress-multi-env-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudio24%2Fwordpress-multi-env-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudio24%2Fwordpress-multi-env-config/lists"}