nyco/wp-config 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nyco/wp-config

Composer 安装命令:

composer require nyco/wp-config

包简介

A WordPress package for environment configuration.

README 文档

README

A developer plugin for WordPress that sets constants and WordPress Options for an installation through a YAML configuration file and autoloads environment specific configuration scripts.

Features

  • Define constants from a .yml file.
  • Set WordPress options from the same .yml file.
  • Optionally encrypt the .yml file secrets.
  • Autoload default .php configuration file.
  • Autoload environment specific .php configuration file.

Installation using Composer

$1 This package uses Composer Installers to install the package in the Must Use plugins directory (/wp-content/mu-plugins):

composer require nyco/wp-config

Not using Composer? Download an archive of the code and drop it into the mu-plugins directory.

$2 Create a proxy PHP loader file inside the mu-plugins directory, or use the one included with the plugin:

mv wp-content/mu-plugins/wp-config/autoloader-sample.php wp-content/mu-plugins/@config.php

Usage

Recommendations

Secure the config.yml file and env.php described below by A) using the encryption method to encrypt the secrets file and B) not checking either file into your site's source control.

Configuration

The package comes with a sample config directory /config-sample. Copy the directory, place into the mu-plugins, and rename it to config.

mv wp-content/mu-plugins/wp-config/config-sample wp-content/mu-plugins/config

In the directory you'll find the following files:

default.php - This is the default configuration script for writing global configurations for your site.

development.php - This is a sample configuration script that would be required if you set the WP_ENV constant to development. You can add as many environments as you would like, but you need to set them (see below).

config.yml - This file will be automatically loaded and read for your different environments. For example:

development:
    SOME_VAR: someVarHere

The SOME_VAR constant would be set for your development environment. It would be available to your WordPress plugins and themes through SOME_VAR or constant('SOME_VAR'). You can add as many environments as you would like, but you need to set them (see below). It is recommended to add the config.yml file to your .gitignore if you are storing private keys so they aren't committed to source control.

Setting your environment

Simply add the following to your wp-config.php to set your environment variable:

$_ENV['WP_ENV'] = 'development';
define('WP_ENV', $_ENV['WP_ENV']);

Setting WordPress Options

To set database options in the WordPress Installation, prefix the the variables in the config.yml file with WP_OPTION_. For example:

development:
    WP_OPTION_SOME_VAR: someVarHere

Encryption

The encryption method is optional. To utilize this method, you will need to generate a secret key to encrypt and decrypt your config.yml secrets.

  1. Clone or download the repository down and cd into the directory.
  2. Run php Secret.php. This will generate a new secret key in an env.php file.
  3. Place your config.yml from the mu-plugins/config directory you created into the same directory and run php Encrypt.php to encrypt the file.
  4. Add the env.php to the mu-plugins/wp-config plugin directory in your WordPress installation.
  5. Add the config.yml file back to the mu-plugins/config directory.

It is recommended to add the config.yml and env.php file to your .gitignore if you are storing private keys so they aren't committed to source control.

Hooks

The action nyco_wp_config_loaded is fired after the default.php, environment.php, and config.yml file are loaded and variables are set.

Contributing

Clone repository and create feature branch. Make changes and run composer run lint to follow the coding specification. composer run format can help fix some of the issues.

The Mayor's Office for Economic Opportunity

The Mayor's Office for Economic Opportunity (NYC Opportunity) is committed to sharing open source software that we use in our products. Feel free to ask questions and share feedback. Interested in contributing? See our open positions on buildwithnyc.github.io. Follow our team on Github (if you are part of the @cityofnewyork organization) or browse our work on Github.

nyco/wp-config 适用场景与选型建议

nyco/wp-config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 258 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「configuration」 「wordpress」 「environment」 「constants」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nyco/wp-config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nyco/wp-config 我们能提供哪些服务?
定制开发 / 二次开发

基于 nyco/wp-config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 258
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 14
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-03-29