2017 © Pedro Peláez
 

library wp-composer-config

Auto generate your wp-config as Composer Script

image

wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  • Wednesday, March 4, 2015
  • by wecodemore
  • Repository
  • 3 Watchers
  • 11 Stars
  • 76 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 3 % Grown

The README.md

Auto generate your wp-config.php

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Usage as Composer post-package-install script. Auto generation of wp-config.php files for WordPress installs. This package mostly is a convenience package that should make the build process easier., (*2)

What is it?

This package is a wp-config.php generator for WordPress that runs as Composer Script. It is based up on Vance Lucas PHPDotEnv package that offers a solution for adding a not version controlled/ignored .env file. The key/value data is made available as getenv(), $_ENV and $_SERVER variable afterwards. This config generator fetches a maintained list of configurable WordPress constants (like DB credentials) and builds a wp-config.php file in the WordPress root directory. This does not make increase security, but it helps preventing that you push sensitive information to a version controlled repository. It also makes it easier to maintain different environments like development, staging and production., (*3)

Example:, (*4)

Example of the CLI process, (*5)

How To: Setup

We recommend to use something like Andreys/"@Rarst" recipe for a site stack to get a thoughtful base structure for your project. Simply add this package to your stack., (*6)

"config" : {
    "vendor-dir": "wp-content/vendor"
},
// ...
"require" : {
    // ... other software installed to /var/www/wp-content/vendor
    "wecodemore/wp-composer-config" : "1.x-dev"
},

Then setup the script, (*7)

"scripts" : {
    "post-package-install" : [
        "WCM\\WPComposerConfig\\WPConfigCommand::postPackageInstall"
    ]
},

Finally the script needs some variable set for the extra object:, (*8)

"extra"   : {
    "wordpress-install-dir" : "path/to/wordpress",
    "wordpress-env-dir"     : "path/to/the/.env/file
 }

That's it., (*9)

If you want to run it on demand, you might want to give it a custom name that you can refer to on the command line. Avoid config as this is an internal Composer command:, (*10)

"scripts" : {
    "wp-config" : [
        "WCM\\WPComposerConfig\\WPConfigCommand::postPackageInstall"
    ]
},

This way you can simply enter, (*11)

composer wp-config

in your CLI and run it whenever it pleases you., (*12)

How To: Use it

The check list:, (*13)

  1. Make sure that you add .env to your .gitignore file
  2. Take a look at the /ci folder in this package and copy the .env.example contents to your projects .env file. This is a blueprint of all major versions
  3. Adjust the settings that you find there
  4. Add the setup steps described above to your composer.json file
  5. Open your CLI and enter composer install
  6. Auth keys and Salt get fetched directly from the wordpess.org servers

Options

The following options are mirrored by the package over from PHPDotEnv:, (*14)

Comment: Prefix a line with #., (*15)

Empty string: Set a = after your key without a value, (*16)

The following option is new and only works for auto generating the wp-config.php file. This should make it easier to test different settings without adding and deleting the same constants over and over again., (*17)

Use WP Default: Set neither a =, nor a value for that key. Or just don't set it at all., (*18)

Internals

The package does not overwrite already existing Auth Keys and Salts. If you need them to be regenerated, please just delete them from the config by hand. They will get added again with a new set of hashes directly from wp.org., (*19)

FAQ

Q: I need Multisite

A: Switching from the (default) single site install to a multi site install is a multi step process that involves user interaction, changing the .htaccess file and adding constants step by step. We don't want to mess up your repo, so we don't do that by now. But if you think you can make it happen, just fork the repo and send a Pull Request., (*20)

Q: Shall I install it from GitHub or from Packagist?

A: The package is on Packagist and auto updated from GitHub instantly (using WebHooks)., (*21)

Q: Will you implement X?

A: Just ask in a new issue. We discuss everything with everyone. If you got a PR, even better., (*22)

Q: What version should I refer to in my composer.json?

A: We use semantic versioning, so you will want to stay up to date with major versions., (*23)

The Versions

04/03 2015

dev-master

9999999-dev https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config

04/03 2015

v1.0.9

1.0.9.0 https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config

17/11 2014

1.0.8

1.0.8.0 https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config

17/11 2014

v1.0.7

1.0.7.0 https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config

17/11 2014

1.0.6

1.0.6.0 https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config

20/10 2014

1.0.0

1.0.0.0 https://github.com/wecodemore/wp-composer-config

Auto generate your wp-config as Composer Script

  Sources   Download

MIT

The Requires

 

wordpress wp config composer env wp-config