wearerequired/composer-wp-config
Composer 安装命令:
composer require wearerequired/composer-wp-config
包简介
A composer plugin to create the WordPress configuration file which automagically defines constants from a .env file. Also includes path of Composer's autoloader in wp-config.php.
README 文档
README
A plugin for Composer to create the WordPress configuration file which automagically defines constants from a .env file. Also includes path of Composer's autoloader in wp-config.php.
Installation
Via Composer
composer require johnpbloch/wordpress wearerequired/composer-wp-config
Copy .env.example and save it as .env. By default the variables are searched in a .env file in the same directory as wp-config.php .
List of required variables
_HTTP_HOST(Used when$_SERVER['SERVER_NAME']is not set, like WP-CLI.)DB_NAMEDB_USERDB_PASSWORDAUTH_KEYSECURE_AUTH_KEYLOGGED_IN_KEYNONCE_KEYAUTH_SALTSECURE_AUTH_SALTLOGGED_IN_SALTNONCE_SALT
See also the list of default constants.
Customize path to .env file
You can override the path(s) with the following extra in your composer.json:
{
"extra": {
"wp-config-env-paths": [
"../",
"../configs"
]
}
}
Note that the path must be relative to the wp-config.php file. Run composer build-wp-config to rebuild the wp-config.php file.
Features
- Creates
wp-config.phpone level above the WordPress installation. - The
wp-config.phpincludes the path to Composer's autoloader. - Searches for
.envfile with the help of PHP dotenv. - Defines all variables as constants unless a constant is already set.
- Defines reasonable default values for database, object cache, debug, URL, and path constants.
- Use
{{DIR}}as placeholder in variable values to get it replaced with__DIR__ofwp-config.php. - Supports
URL_DEVELOPMENT,URL_STAGING, andURL_PRODUCTIONfor WordPress Stage Switcher. Requires at least v2.1. - Supports loading
wp-config-prepend.phpbefore andwp-config-append.phpafter the default config as part ofwp-config.php. - Loads the WordPress plugin API early so actions and filters can be used.
Default Constants
If the following variables are not defined they will be assigned a default value:
| Variable name | Default value |
|---|---|
WP_ENV |
'development' |
WP_ENVIRONMENT_TYPE |
Value of WP_ENV |
QM_DISABLED |
true |
SAVEQUERIES |
false |
WP_DEBUG |
false |
WP_DISABLE_FATAL_ERROR_HANDLER |
Value of WP_DEBUG |
WP_DEBUG_LOG |
false |
WP_DEBUG_DISPLAY |
false |
SCRIPT_DEBUG |
false |
DISALLOW_FILE_MODS |
true |
DB_HOST |
'localhost' |
DB_CHARSET |
'utf8' |
DB_COLLATE |
'' |
$table_prefix |
'wp_' |
WP_CACHE_KEY_SALT |
Value of WP_ENV |
WP_HOME |
Based on $_SERVER['SERVER_NAME']/_HTTP_HOST and $_SERVER['HTTPS'] |
WP_SITEURL |
Value of WP_HOME |
WP_CONTENT_FOLDER_NAME |
'content' |
WP_CONTENT_DIR |
__DIR__ . '/' . WP_CONTENT_FOLDER_NAME |
WP_CONTENT_URL |
WP_HOME . '/' . WP_CONTENT_FOLDER_NAME |
Planned Features
- Allow to change required variables via
composer.json. - Allow to change variables not used as a constant via
composer.json. - Let us know what you think is missing…
wearerequired/composer-wp-config 适用场景与选型建议
wearerequired/composer-wp-config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.7k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「autoload」 「wordpress」 「config」 「wp」 「env」 「dotenv」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wearerequired/composer-wp-config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wearerequired/composer-wp-config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wearerequired/composer-wp-config 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Environment processor and contexts autoloader
A Zend Framework module to quickly and easily set PHP settings.
Extension to autoload modules dynamically
Server environment detection based on config array-file
Class loader implementation (PSR-0, PSR-4)
A small autoloading library, compatible with Composer, that allows you to customise your autoloading functionality.
统计信息
- 总下载量: 20.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-28