Contribute to the Platform.sh knowledge base, or check out our resources
Join our community
Blog
Documentation
Platform.sh maintains a list of scripts that may be used within the template to ease its fine-tuning.
raw.githubusercontent.com rate limitInstall a specific version of Node on non-Node JS containerPlatformify scriptInstall Swoole
On rare occasion, the rate limit on raw.githubusercontent.com my be hit. It can
then be recommended to use a Personal Token to benefit
from a much higher rate limit.
curl -H "Authorization: Bearer PERSONAL_TOKEN" -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/script.sh | { bash /dev/fd/3 PARAMETERS; } 3<&0
The documentation describes how to specify the Node version to use and/or how to add Yarn to the NodeJS container.
For other containers, such as the PHP one, it may be needed to rely on a specific version of NodeJS, and use Yarn as well.
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$PATH
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v lts; } 3<&0
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$PATH
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v 17.5 -y; } 3<&0
An example build hook is listed below. If using this snippet, do not add corepack as a build dependency as outlined in the Platform.sh documentation, as it is already done for you. With the -y flag, the hook below will install Node.js 14.19.0 along with Yarn, afterwhich yarn commands can be run through corepack.
name: app
type: php:8.0
dependencies:
php:
composer/composer: '^2'
variables:
env:
NODE_VERSION: v14.19.0
build:
flavor: none
hooks:
build: |
set -e
composer install
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$PATH
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_node.sh | { bash /dev/fd/3 -v $NODE_VERSION -y; } 3<&0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 corepack yarn install
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 corepack yarn packages:build
corepack yarn run less
corepack yarn run webpackNote:
By default,
nwill try and install to/usr/local/n, which is not allowed on Platform.sh. You can instead specify the install location using the variableN_PREFIXand then adding toPATH. If you will also neednoutside of the build hook, add the twoexportlines to.environmentas well.
The platformify script will download the .platform.app.yaml file and all the
files needed to run a specific project on Platform.sh.
To platformify a Laravel project:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/platformify.sh | { bash /dev/fd/3 -t laravel ; } 3<&0
To platformify a Laravel project and a speficic folder:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/platformify.sh | { bash /dev/fd/3 -t laravel -p path/to/dir ; } 3<&0
When ran on an empty folder, the script will clone the full template.
The install_swoole script will install and enable the Swoole or Open Swoole extension in a PHP container.
To install Open Swoole v4.11.0:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh | { bash /dev/fd/3 openswoole 4.11.0 ; } 3<&0
To install Swoole v4.8.10:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install_swoole.sh | { bash /dev/fd/3 swoole 4.8.10 ; } 3<&0
The install-relay script will install and enable the Relay extension in a PHP container.
To install Relay v0.6.0:
Note the version should be prefixed with v (v0.6.0)
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-relay.sh | { bash /dev/fd/3 v0.6.0 ; } 3<&0
To install Relay @dev:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-relay.sh | { bash /dev/fd/3 dev ; } 3<&0
The install-phpredis script will install and enable the PhpRedis extension in a PHP container.
To install PhpRedis v5.1.1:
curl -fsS https://raw.githubusercontent.com/platformsh/snippets/main/src/install-phpredis.sh | { bash /dev/fd/3 5.1.1 ; } 3<&0
The region-audit script with list projects within a Platform.sh or Upsun organization that are deployed to some subset of regions.
To run the script for Platform.sh
https://raw.githubusercontent.com/platformsh/snippets/main/src/region-audit.sh | bash -s -- [ORG_NAME] [REGIONS] [platform|upsun]For example
https://raw.githubusercontent.com/platformsh/snippets/main/src/region-audit.sh | bash -s -- my-org ch-1,uk-1,de-2,us-4 platform