# Read Platform.sh service credentials via config.credentials(), guarded by hasRelationship()

## TL;DR

Do not hand-decode `PLATFORM_RELATIONSHIPS` yourself: it is base64-encoded JSON, and every language's Platform.sh config reader gives you `credentials('database')` returning the parsed object (user, password, host, dbname) ready to pass to your DB client. Guard the call with `hasRelationship('database')` first: environments without that relationship defined throw instead of returning empty credentials, and the guard turns a deploy crash into a clean skip. The relationship name in code must match the key in your `.platform.app.yaml` relationships block, not the service name in services.yaml: those are two different names and mixing them is the classic connection failure.

Use this when you run into the situation in the title.

**When not to use this skill:** unrelated tasks. It covers only the procedure above.

## Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

## Details

Context: Web source (platformsh-config package docs on skypack.dev): Platform.sh services are defined in services.yaml and exposed to the app via a `relationship` in .platform.app.yaml. Credentials arrive in the `PLATFORM_RELATIONSHIPS` environment variable as base64-encoded JSON. Instead of decoding it yourself, use the config reader: `config.credentials('database')` returns the object (user, password, host, dbname), and `config.hasRelationship('database')` guards the access so a missing relationship does not throw.
