maxserv/ composer-application-context
此包的最新版本(1.0.2)没有可用的许可证信息。
1.0.2
2020-03-06 12:21 UTC
Requires
- composer-plugin-api: ^1.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-06 22:17:22 UTC
README
此插件通过修补入口文件(如index.php)设置一些额外的环境变量。在无法设置FCGI变量的环境中,此插件修补了一个定义的PHP文件列表,使用适当的putenv
调用引导程序,使应用程序“认为”它正在运行在特定环境中。
"extra": {
"application-context": {
"paths": [
"index.php"
],
"variables": {
"APPLICATION_CONTEXT": "%env(APPLICATION_CONTEXT)%"
}
}
}
应在composer.json中的extra下配置要设置并包含在生成的片段中的变量。还应在此处配置应修补的文件。
以下示例片段添加到每个文件的顶部。
// Prefixed by MaxServ\ComposerApplicationContext\Plugin
call_user_func(function(){
if (function_exists('getenv') !== false && function_exists('putenv') !== false){
if ('%env(APPLICATION_CONTEXT)%' !== '' && stripos('%env(APPLICATION_CONTEXT)%', '%env(') === false) {
if (getenv('APPLICATION_CONTEXT') === false){putenv('APPLICATION_CONTEXT=%env(APPLICATION_CONTEXT)%');}
if ($_SERVER['APPLICATION_CONTEXT'] === null){$_SERVER['APPLICATION_CONTEXT'] = '%env(APPLICATION_CONTEXT)%';}
}
}
});
在运行时,在调用getenv
和putenv
之前评估变量(该变量可能被另一个脚本替换)。