定制 pikselin/platform-sh 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pikselin/platform-sh

Composer 安装命令:

composer require pikselin/platform-sh

包简介

README 文档

README

This module is to take every environment variable set in platform.sh, and make it accessible to the Silverstripe configuration/environment.

Installation

composer require pikselin/platform-sh

Copy (manually, sorry), vendor/pikselin/platform-sh/.environment to your project root.

This bash script will set the environment variable based on what's set in the Platform console for SS_ENVIRONMENT_TYPE

Usage

In your _config.php, init the platform-sh:

<?php

use Pikselin\Platform\PlatformService;

PlatformService::init();

Environment hardening.

To prevent environment variables from leaking, the allowed environment variables are listed and checked.

Note that explicitly the environment type is excluded in the list of allowed variables.

This is to avoid doubling up after it's already been set by the shell script.

To add your own list of allowed keys, create a YML like so:

---
name: 'my-allowed-envs'
after: 'platformsh-config'
---
Pikselin\Platform\PlatformService:
  env_variables:
    - MY_ADDITIONAL_KEY

If you're adding the SS_MFA_SECRET_KEY, you'll have to add this the following line to the .environment file too:

export SS_MFA_SECRET_KEY=$(echo $PLATFORM_VARIABLES | base64 --decode | jq -r ".SS_MFA_SECRET_KEY")

It's possible other .env variables work that way too.

Troubleshooting

If you're getting a server error or you find something like this in the logs Uncaught Exception TypeError: "in_array(): Argument #2 ($haystack) must be of type array, null given"

SSH into server

platform ssh

And remove the cache manually

rm -rf silverstripe-cache/web/*

Even though it is in the build/deploy hooks, it seems like they need to be run manually.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-05-15