### Install Dependencies and Start Strapi Server Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/guides/strapi/local-development/local-development-v4.md Installs project dependencies using a frozen lockfile and then starts the Strapi development server. ```bash yarn --frozen-lockfile yarn develop ``` -------------------------------- ### Create Strapi Project (Quickstart) Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/guides/strapi/database-configuration/sqlite.md Create a new Strapi application using the quickstart option. This automatically configures Strapi to use SQLite as its default database, simplifying initial setup. ```bash npx create-strapi-app ``` -------------------------------- ### Add Custom Domain to Preview Environment Example (Console) Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/domains/steps/custom-domains-preview-environments.md Step-by-step guide for adding a custom domain to a preview environment via the Platform.sh Console, using a specific example. ```text 1. Get the target for `Dev`.
To do so, navigate to `Dev` and click **{{< icon settings >}} Settings**.
Select the **Domains** tab.
In the **Configure your domain** section, copy the content of the **CNAME record** field.
Save it for later use at step 7. 2. Click **Add domain**. 3. Enter `mydev.com` as a name for the custom domain you want to add to `Dev`. 4. Select `mysite.com` as the production custom domain you want to attach `mydev.com` to. 5. Click **Add**.
6. Click **Okay**. 7. [Configure your DNS provider](../steps/_index.md#2-configure-your-dns-provider).
In particular, make sure your DNS record points to `Dev`'s target. ``` -------------------------------- ### Ruby Unicorn Start Command (Commented) Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/ruby.md Provides a commented-out example for starting the Unicorn web server using a Unix socket. Uncomment and adapt if you prefer Unicorn over Puma. ```yaml # for unicorn # start: "bundle exec unicorn -l $SOCKET" ``` -------------------------------- ### API Command Configuration Example Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html Shows the configuration for pre_start, start, and post_start commands within an API. ```json { "commands": { "pre_start": "string", "start": "string", "post_start": "string" } } ``` -------------------------------- ### Install Go Continuous Profiler Library Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/increase-observability/application-metrics/go.md Use 'go get' to install the Blackfire Continuous Profiler Go library. ```bash go get github.com/blackfireio/go-continuous-profiling ``` -------------------------------- ### Example Commands Source: https://github.com/platformsh/platformsh-docs/blob/main/contributing/templates/how-to.md Illustrates how to list commands that users need to run as part of a step in a how-to guide. ```markdown 1. Run `command --options`. 1. Run `other_command --options`. 1. Run `third_command --options`. ``` -------------------------------- ### Example Network Storage Configuration Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/add-services/network-storage.md An example of configuring a network storage service and mounting it to an application. This demonstrates a typical setup for a single application. ```yaml applications: # The name of the app container. Must be unique within a project. myapp: mounts: 'my/files': source: service service: network-storage source_path: files services: # The name of the service container. Must be unique within a project. network-storage: type: network-storage:{{% latest "network-storage" %}} ``` -------------------------------- ### Complete Node.js App Configuration Example Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/nodejs/_index.md A comprehensive example of a basic Node.js application configuration, including name, type, disk size, dependencies, build hooks, and start command. ```yaml name: node-app type: 'nodejs:{{% latest "nodejs" %}}' disk: 512 dependencies: nodejs: sharp: "*" hooks: build: | npm run setup-assets npm run build web: commands: start: "node index.js" ``` -------------------------------- ### Example Node.js Application with Continuous Profiler Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/increase-observability/application-metrics/nodejs.md An example Express application demonstrating the integration of the Blackfire Continuous Profiler. It installs necessary packages, sets up a basic route, and starts the profiler with an application name upon server startup. ```shell npm install express @blackfireio/node-tracing ``` ```javascript const Blackfire = require('@blackfireio/node-tracing'); const express = require('express') const crypto = require("crypto"); const app = express() const port = 3000 app.get('/', (req, res) => { const salt = crypto.randomBytes(128).toString("base64"); const hash = crypto.pbkdf2Sync("this is my password", salt, 10000, 512, "sha512"); res.send('Hello World!'); }) app.listen(port, () => { console.log(`Example app listening on port ${port}`) Blackfire.start({appName: 'blackfire-example'}); }) ``` -------------------------------- ### Initialize Environment with Files Example Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html Example of initializing an environment with a repository and additional files to be committed. ```json { "repository": "git@github.com:platformsh/a-project-template.git@master", "profile": "Example Project", "files": [ { "mode": 0600, "path": "config.json", "contents": "XXXXXXXX" } ] } ``` -------------------------------- ### Install platformsh-config with bun Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/get-started/here/configure/nodejs.md Example of installing the platformsh-config package using bun. ```bash bun install platformsh-config ``` -------------------------------- ### Accessing Services with Go Configuration Reader Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/go.md Use the Platform.sh Go helper library to access environment information and configuration. This example demonstrates how to initialize the library and set up an HTTP server. ```go package main import ( _ "github.com/go-sql-driver/mysql" psh "github.com/platformsh/gohelper" "net/http" ) func main() { p, err := psh.NewPlatformInfo() if err != nil { panic("Not in an {{% vendor/name %}} Environment.") } http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { // ... }) http.ListenAndServe(":"+p.Port, nil) } ``` -------------------------------- ### Install platformsh-config with npm Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/get-started/here/configure/nodejs.md Example of installing the platformsh-config package using npm. ```bash npm install platformsh-config ``` -------------------------------- ### Resource Configuration Example Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api-internal.html Shows a sample configuration for CPU and memory resources, including properties with min/max values. ```json { "resources": { "cpu": { "property1": { "min": 0, "max": 0 }, "property2": { "min": 0, "max": 0 } }, "memory": { "property1": { "min": 0 } } } } ``` -------------------------------- ### Platform CLI: activity:get Example - Last Activity Duration Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/administration/cli/reference.md Example of how to find the duration of the last activity using the activity:get command. It retrieves the 'duration' property. ```bash platform activity:get -P duration ``` -------------------------------- ### Get help for a specific CLI command Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/administration/cli/_index.md To understand a specific command, preface it with 'help'. This example shows how to get help for the 'get' command. ```bash {{% vendor/cli %}} help get ``` -------------------------------- ### Post-start command for application readiness Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/learn/overview/build-deploy.md This example demonstrates a `post_start` command to ensure an application is fully active and listening on the correct port before receiving traffic. It includes a curl command to check localhost readiness with retries. ```yaml web: commands: post_start: | date curl -sS --retry 20 --retry-delay 1 --retry-connrefused localhost -o /dev/null ``` -------------------------------- ### Platform CLI: activity:get Example - Project Creation Time Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/administration/cli/reference.md Example of how to find the creation time of a project using the activity:get command. It filters for 'project.create' activities and retrieves the 'completed_at' property. ```bash platform activity:get --all --type project.create -P completed_at ``` -------------------------------- ### Install npm Dependencies in Docksal Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/development/local/docksal.md Add npm dependency installation to your Docksal `init` command. This ensures that your project's Node.js dependencies are installed when Docksal starts. ```bash #!/usr/bin/env bash fin project rm -f fin project start cd "$PROJECT_ROOT" echo "Installing dependencies..." npm install ``` -------------------------------- ### Complete app.yaml Configuration Example Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/guides/config-app.md This example demonstrates a comprehensive app.yaml configuration file. It includes comments explaining various settings for runtime, dependencies, environment variables, and more. Use this as a template for your own application configurations. ```yaml name: "My Application" # The type of application. This can be a language runtime (e.g., php, python, node) or a service (e.g., database, cache). # See https://docs.platform.sh/create-apps/app-reference/single-runtime-image.md for a complete list. type: "php:8.2" # The directory containing the application's code. Defaults to the root of the project. # webroot: "public" # The command to start the application. Defaults to the language's default command. # runtime: "vendor/bin/server" # The port the application listens on. Defaults to the language's default port. # port: 8000 # The document root for the web server. Defaults to the webroot. # document_root: "public" # The index file for the web server. Defaults to index.php. # index: "index.php" # The error log file. Defaults to logs/error.log. # error_log: "logs/error.log" # The access log file. Defaults to logs/access.log. # access_log: "logs/access.log" # The cron jobs configuration. # cron: # - name: "My Cron Job" # schedule: "* * * * *" # command: "php cron.php" # The environment variables configuration. # environment: # MY_VARIABLE: "my_value" # ANOTHER_VARIABLE: "another_value" # The relationships configuration. # relationships: # database: "database:default" # cache: "cache:default" # The mounts configuration. # mounts: # - source: "/data" # destination: "/app/data" # The build configuration. # build: # flavor: "composer" # # The command to run during the build process. # # command: "composer install" # The deploy configuration. # deploy: # # The command to run after deployment. # # command: "php artisan cache:clear" # The hooks configuration. # hooks: # build: # # The command to run during the build process. # # command: "echo 'Building...' ``` -------------------------------- ### Initialize a Project Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/administration/cli/reference.md Initializes a new project, generating starter configuration files. Supports AI-assisted configuration and provides options for context and digest viewing. ```bash upsun init ``` ```bash upsun project:init ``` ```bash upsun project:init --ai=false ``` ```bash upsun project:init --ai --context='Use PostgreSQL for the database' ``` -------------------------------- ### Set up Virtual Environment Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/get-started/stacks/flask.md Create and activate a Python virtual environment for your project. ```bash python3 -m venv env && source venv/bin/activate ``` -------------------------------- ### Custom Build Flavor with Composer Install Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/languages/php/_index.md Set the build flavor to `none` in `app.yaml` and define custom build commands to control dependency installation. This example installs production dependencies only. ```yaml applications: myapp: type: 'php:{{% latest "php" %}}' build: flavor: none hooks: build: | set -e composer install --no-interaction --no-dev ``` -------------------------------- ### Install ddev-platformsh Add-on Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/ddev/connect.md Install the Platform.sh add-on for DDEV to enable integration with your Platform.sh project. This command initiates an interactive setup process. ```bash ddev get ddev/ddev-platformsh ``` -------------------------------- ### Create Starter YAML File Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/administration/cli/reference.md Use this command to generate the initial YAML configuration files for your project. ```bash platform project:init ``` -------------------------------- ### Create Project Option Response Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api-internal.html Example response after successfully creating a project option, showing default and enforced configurations. ```json { "defaults": { "settings": { }, "variables": { }, "access": { }, "capabilities": { } }, "enforced": { "settings": { }, "capabilities": { } }, "regions": [ "string" ], "plans": [ "string" ], "billing": { } } ``` -------------------------------- ### Start and Manage DDEV Environment Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/guides/django/local/ddev.md Commands to start, pull necessary images, and restart the DDEV environment. Ensure your DDEV setup is up-to-date. ```bash ddev start ddev pull {{< vendor/cli >}} -y ddev restart ``` -------------------------------- ### Configure Go Application Build and Run Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/go.md This configuration sets up a Go application, including build commands and start commands. Ensure the build output path matches the start command. ```yaml name: myapp type: golang:1.14 hooks: build: | # Modify this line if you want to build differently or use an alternate name for your executable. go build -o bin/app web: upstream: socket_family: tcp protocol: http commands: # If you change the build output in the build hook above, update this line as well. start: ./bin/app locations: "/": # Route all requests to the Go app, unconditionally. allow: false passthru: true disk: 1024 ``` -------------------------------- ### Get All Setup Options Response Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api-internal.html This JSON structure represents the response when retrieving all setup options from the API. It includes counts, items, and pagination links. ```json { "count": 0, "items": [ { "defaults": { "settings": {}, "variables": {}, "access": {}, "capabilities": {} }, "enforced": { "settings": {}, "capabilities": {} }, "regions": [ "string" ], "plans": [ "string" ], "billing": {} } ], "_links": { "self": { "href": "string" }, "previous": { "href": "string" }, "next": { "href": "string" } } } ``` -------------------------------- ### Example App Configuration Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/add-services/network-storage.md Example configuration for mounting a network storage service within an application. ```yaml name: myapp mounts: 'my/files': source: service service: network-storage source_path: files ``` -------------------------------- ### Example build hook with Redis Object Cache Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/guides/wordpress/redis.md An example of a complete build hook that includes installing Redis, copying plugins, and configuring the Redis Object Cache plugin. ```yaml hooks: build: | set -e bash .platform-scripts/install-redis.sh 6.0.12 # Copy manually-provided plugins into the plugins directory. # This allows manually-provided and composer-provided plugins to coexist. rsync -a plugins/* wordpress/wp-content/plugins/ if [ -f wordpress/wp-content/plugins/redis-cache/includes/object-cache.php ]; then cp wordpress/wp-content/plugins/redis-cache/includes/object-cache.php wordpress/wp-content/object-cache.php fi ``` -------------------------------- ### Example Application Instance Details Output Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/manage-resources/adjust-resources.md Example JSON output from the `/run/peers.json` file, showing application instance names and their corresponding IP addresses. ```json { "hello_distributed.1": "123.456.789.10", "hello_distributed.3": "123.456.789.20", "hello_distributed.2": "123.456.789.30", "hello_distributed.0": "123.456.789.40" } ``` -------------------------------- ### Fetch API - Synchronous GET Request Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/integrations/activity/_index.md Example of making a synchronous GET request using the `fetch` API. The response object's properties and methods are directly accessible. ```javascript var resp = fetch("http://example.com/site-deployed"); if (!resp.ok) { console.log("Well that didn't work."); } ``` -------------------------------- ### Example: Two Database Services Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/add-services/_index.md This example shows how to configure two different database services, MariaDB and PostgreSQL, in the `services.yaml` file. Each service has a unique name and specifies its type and disk size. ```yaml mariadb: type: mariadb:{{% latest "mariadb" %}} disk: 2048 postgresql: type: postgresql:{{% latest "postgresql" %}} disk: 1024 ``` -------------------------------- ### Example Bitbucket Integration Command Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/source-integration/enable-integration.html This is an example command for adding a Bitbucket integration, demonstrating the expected format for project ID, repository, consumer key, and consumer secret. ```bash integration:add \ --project abcdefgh1234567 \ --type bitbucket \ --repository platformsh/platformsh-docs \ --key abcd1234 \ --secret abcd1234 ``` -------------------------------- ### Example Scaling and Resource Configuration Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html This snippet shows a detailed configuration for scaling parameters, including instance limits, resource allocations for CPU and memory, and scale factor/cooldown settings. ```json { }, * "up": { * "threshold": 100, * "duration": 60, * "enabled": true } } } }, * "instances": { * "min": 0, * "max": 0 }, * "resources": { * "cpu": { * "property1": { * "min": 0, * "max": 0 }, * "property2": { * "min": 0, * "max": 0 } }, * "memory": { * "property1": { * "min": 0, * "max": 0 }, * "property2": { * "min": 0, * "max": 0 } } }, * "scale_factor": { * "up": 0, * "down": 0 }, * "scale_cooldown": { * "up": 0, * "down": 0 } }, * "property2": { * "triggers": { * "cpu": { * "property1": { * "enabled": true, * "down": { * "threshold": 100, * "duration": 60, * "enabled": true }, * "up": { * "threshold": 100, * "duration": 60, * "enabled": true } }, * "property2": { * "enabled": true, * "down": { * "threshold": 100, * "duration": 60, * "enabled": true }, * "up": { * "threshold": 100, * "duration": 60, * "enabled": true } } }, ``` -------------------------------- ### Configure Swoole Start Command in app.yaml Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/languages/php/swoole.md This configuration snippet shows how to override the default web server with a custom start command for Swoole Octane. It specifies that the application should listen on a TCP socket and defines the start command to use the Swoole installation script. ```yaml applications: myapp: type: 'php:{{% latest "php" %}}' web: upstream: socket_family: tcp protocol: http commands: start: php {{}} --port=$PORT locations: "/": passthru: true scripts: false allow: false ``` -------------------------------- ### Example Bitbucket Server Integration Command Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/source-integration/enable-integration.html This is an example command for adding a Bitbucket Server integration, demonstrating the expected format for project ID, repository, username, server URL, and access token. ```bash integration:add \ --project abcdefgh1234567 \ --type bitbucket_server \ --username user@example.com \ --token abc123def456 \ --bitbucket-url https://bitbucket.example.com \ --repository platformsh/platformsh-docs ``` -------------------------------- ### Define Python Web Server Start Command Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/languages/python/_index.md Configure the 'start' command for your Python web application. This example uses 'python server.py', but you can adapt it for other servers like Daphne, Gunicorn, Hypercorn, or Uvicorn. ```yaml applications: # The app's name, which must be unique within the project. myapp: type: 'python:{{% latest "python" %}}' web: # Start your app with the configuration you define # You can replace the file location with your location commands: start: python server.py ``` -------------------------------- ### Create and Initialize Local Setup Script Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/development/local/tethered.md Create an executable shell script to set up a local development environment for a new Platform.sh environment. ```bash touch init-local.sh && chmod +x init-local.sh ``` ```bash #!/usr/bin/env bash ENVIRONMENT=$1 PARENT=$2 # Create the new environment {{< vendor/cli >}} branch $ENVIRONMENT $PARENT # Open a tunnel to the current environment {{< vendor/cli >}} tunnel:open --no-interaction # Mock {{< vendor/name >}} environment variables export PLATFORM_RELATIONSHIPS="$({{< vendor/cli >}} tunnel:info --encode)" # Add any other variables you need # If necessary, install dependencies here # Add the command to run the server ``` -------------------------------- ### Get Login Connection Response Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html Example JSON response for retrieving a specific federated login connection. ```json { "provider": "string", "provider_type": "string", "is_mandatory": true, "subject": "string", "email_address": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ``` -------------------------------- ### Example Project Settings Response Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html This JSON snippet shows an example response when retrieving project settings. It includes various boolean flags related to project configuration. ```json { "allow_scaling_to_zero": true, "save_applications_vendors": true, "locations_script_default": true, "support_oci_images": true } ``` -------------------------------- ### Set Up Local Environment Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/guides/symfony/local-next-steps-end.md These commands are used to set up a local development environment by fetching project details, navigating to the project directory, and initializing the local environment with specific branch and ID. ```bash symfony get {{< variable "PROJECT_ID" >}} cd {{< variable "PROJECT_NAME" >}} ./init-local.sh {{< variable "PROJECT_ID" >}} another-new-feature main ``` -------------------------------- ### Install Composer 2 and Package from Custom Repository Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/php/_index.md This example combines enabling Composer 2.x and installing a specific package from a custom VCS repository. It ensures both the Composer version and the package source are correctly configured. ```yaml dependencies: php: require: composer/composer: '^2' "platformsh/client": "2.x-dev" repositories: - type: vcs url: "git@github.com:platformsh/platformsh-client-php.git" ``` -------------------------------- ### Instance and Resources Configuration Sample Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html This sample shows the basic structure for defining instance limits (min/max) and resource allocation. ```json { "instances": { "min": 0, "max": 0 }, "resources": { ... } } ``` -------------------------------- ### Initialize a Project Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/administration/cli/reference.md Initialize a project by generating a starter configuration. This can be done using AI, which sends a sanitized repository digest to OpenAI for analysis, or by following a step-by-step guide. ```bash platform init ``` -------------------------------- ### Get Projects Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html Retrieves a list of projects accessible by the current user. This is an example of how to authenticate and make a request to the API. ```APIDOC ## GET /projects ### Description Retrieves a list of projects accessible by the current user. ### Method GET ### Endpoint https://api.upsun.com/projects ### Authentication Requires a Bearer token in the `Authorization` header. ### Request Example ```bash curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://api.upsun.com/projects ``` ### Response #### Success Response (200) Returns a list of projects. The exact structure may vary, but typically includes project details and HAL links. #### Response Example ```json { "_links": { "self": { "href": "https://api.upsun.com/projects" } }, "embedded": { "projects": [ { "id": "project_id_1", "title": "Project One", "_links": { "self": { "href": "https://api.upsun.com/projects/project_id_1" } } }, { "id": "project_id_2", "title": "Project Two", "_links": { "self": { "href": "https://api.upsun.com/projects/project_id_2" } } } ] } } ``` ``` -------------------------------- ### Run Python Example Script Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/increase-observability/application-metrics/python.md Execute the Python script containing the continuous profiler setup and application logic. ```bash python example.py ``` -------------------------------- ### Example Project Structure Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/create-apps/web/serve-different-directories.md Illustrates a typical project layout with separate directories for application code and documentation source files, along with configuration files. ```text {{% vendor/configdir %}}/ {{< vendor/configfile "routes" "strip" >}} {{< vendor/configfile "services" "strip" >}} {{< vendor/configfile "apps" "strip" >}} application/ [app-code-files] docs-src/ [docs-code-files] ``` -------------------------------- ### Configure Swoole Start Command Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/php/swoole.md Override the default web server to use Swoole by configuring a custom start command in your Platform.sh application settings. This example sets up Swoole to listen on a TCP socket for HTTP traffic. ```yaml web: upstream: socket_family: tcp protocol: http commands: start: php {{}} --port=$PORT locations: "/": passthru: true scripts: false allow: false ``` -------------------------------- ### Example: Configuring Multiple Database Services Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/add-services/_index.md Illustrates how to configure two different database services, MariaDB and PostgreSQL, within the `services.yaml` file. Each service is defined with its type and version. ```yaml services: # The name of the service container. Must be unique within a project. mariadb: type: mariadb:{{% latest "mariadb" %}} # The name of the service container. Must be unique within a project. postgresql: type: postgresql:{{% latest "postgresql" %}} ``` -------------------------------- ### Environment File Setup for Gotenberg Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/add-services/gotenberg.md Example of how to decode and set environment variables for Gotenberg host from the PLATFORM_RELATIONSHIPS variable in a .environment file. ```bash # Decode the built-in credentials object variable. export RELATIONSHIPS_JSON="$(echo "$PLATFORM_RELATIONSHIPS" | base64 --decode)" # Set environment variables for individual credentials. export APP_GOTENBERG_HOST=="$(echo "$RELATIONSHIPS_JSON" | jq -r '.gotenberg[0].host')" ``` -------------------------------- ### Example Configuration (Default Endpoints) Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/add-services/headless-chrome.md A complete example demonstrating the configuration for an application and the Headless Chrome service using default endpoints. ```yaml applications: # The name of the app container. Must be unique within a project. myapp: # Relationships enable access from this app to a given service. # The example below shows simplified configuration leveraging a default service # (identified from the relationship name) and a default endpoint. # See the Application reference for all options for defining relationships and endpoints. relationships: chrome-headless: services: # The name of the service container. Must be unique within a project. chrome-headless: type: chrome-headless:{{% latest "chrome-headless" %}} ``` -------------------------------- ### Python Build Hook with Poetry Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/get-started/build-hook.md Configure your Python build hook to install dependencies using poetry. This example includes setting environment variables and installing poetry if not present. It uses `set -e` to ensure the build fails if any command fails. ```yaml hooks: build: | # Fail the build if any part fails set -e # Install poetry export PIP_USER=false curl -sSL https://install.python-poetry.org | python3 - --version $POETRY_VERSION export PIP_USER=true # Install dependencies poetry install ``` -------------------------------- ### Get Project ID for Non-Symfony Projects Source: https://github.com/platformsh/platformsh-docs/blob/main/themes/psh-docs/layouts/shortcodes/guides/local-requirements.md Use this command to retrieve your project ID when working with non-Symfony frameworks. Ensure you have the Platform.sh CLI installed. ```bash {{< vendor/cli >}} get {{< variable "PROJECT_ID" >}} ``` -------------------------------- ### Create Strapi Project Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/get-started/stacks/strapi/_index.md Use this command to create a new Strapi project with quickstart enabled and without auto-running. ```bash npx create-strapi-app@latest my-strapi-project --quickstart --no-run ``` -------------------------------- ### Strapi Build Configuration Example Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/guides/strapi/deploy/configure.md This snippet shows the default build configuration for a Strapi project using yarn. It installs dependencies and builds the site. ```yaml build: flavor: strapi4 build: | yarn install yarn build ``` -------------------------------- ### Add Initial WordPress and Upsun Configuration Files Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/get-started/stacks/wordpress/composer.md Add the initial WordPress and Upsun configuration files to your project. This includes composer.json, wp-cli.yml, .environment, and wp-config.php. ```bash git add . git commit -m "Adds initial WordPress and Upsun configuration files" ``` -------------------------------- ### Retrieve Headless Chrome Credentials Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/add-services/headless-chrome.md Use the Node.js Config Reader library to get credentials for connecting to headless Chrome. Ensure the 'platformsh-config' library is installed. ```javascript const platformsh = require('platformsh-config'); const config = platformsh.config(); const credentials = config.credentials('chromeheadless'); ``` -------------------------------- ### Example Varnish Service Configuration Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/upsun/src/add-services/varnish.md An example of how to configure a Varnish service, linking it to an application named 'myapp' and specifying the 'config.vcl' file for its VCL configuration. ```yaml applications: # The name of the app container. Must be unique within a project. myapp: ... services: # The name of the service container. Must be unique within a project. varnish: type: varnish:{{% latest "varnish" %}} relationships: application: 'myapp:http' configuration: vcl: !include type: string path: config.vcl ``` -------------------------------- ### Use Bun as a Runtime Source: https://github.com/platformsh/platformsh-docs/blob/main/sites/platform/src/languages/nodejs/_index.md Configure the application to use Bun as the runtime by setting the start command to 'bun app.js', in addition to using Bun for dependency installation. ```yaml # The name of your app. name: myapp # Choose Node.js version 20 or above. type: 'nodejs:20' # Override the default Node.js build flavor. build: flavor: none # Use Bun to install the dependencies. hooks: build: bun install # In the start command replace node with Bun. web: commands: start: 'bun app.js' ``` -------------------------------- ### Command Configuration Source: https://github.com/platformsh/platformsh-docs/blob/main/shared/pages/api.html Define pre-start, start, and post-start commands for application lifecycle management. ```json "commands": { "pre_start": "string", "start": "string", "post_start": "string" } ```