GithubHelp home page GithubHelp logo

isabella232 / wp-composer-config Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wecodemore/wp-composer-config

0.0 0.0 0.0 75 KB

Auto generate your wp-config as Composer Script

PHP 100.00%

wp-composer-config's Introduction

Auto generate your wp-config.php

Latest Stable Version Total Downloads Latest Unstable Version License

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.

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.

Example:

Example of the CLI process

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.

"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

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

Finally the script needs some variable set for the extra object:

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

That's it.

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:

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

This way you can simply enter

composer wp-config

in your CLI and run it whenever it pleases you.

How To: Use it

The check list:

  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:

Comment: Prefix a line with #.

Empty string: Set a = after your key without a value

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.

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

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.

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.

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

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

Q: Will you implement X?

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

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.

wp-composer-config's People

Contributors

franz-josef-kaiser avatar ptica avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.