Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Hi @roxblnfk !
Thanks for opening the PR.
Took a quick look through and it looks like the public interface deviates pretty notably from other implementations, see Typescript.
We have typically offered an interface that allows you to:
- load a client configuration (e.g. all profiles in a configuration) from TOML file and overridden by env vars if set
- load a client configuration, but from provided TOML data and overridden by env vars if set
- convert a client configuration back to its TOML representation (as bytes)
- load a single profile
- load a profile and convert it into a representation that can be immediately used by client/connection (for a quick shorthand way to load and configure your client)
I'm requesting changes such that we keep feature parity here and maintain the same interface in the PHP SDK.
I would also keep in mind the control flow, as it differs in the existing implementations as well (i.e. we only throw ProfileNotFound if a profile name was provided by the user, if not, we return an empty profile)
|
@THardy98 hi. The specification didn't help me understand some mechanics. Could you clarify these questions: Question 1: What is the expected behavior if:
Will the ENV variable values override the options of the different profile, even though the profile is not the configured TEMPORAL_PROFILE? Question 2: If I load configuration from both ENV variables and a TOML config file, and then save the loaded |
|
Yeah, good questions, I could've clarified this earlier.
Yes, the order of precedence is:
With profile name, if you specify it in code, we will use it. Other env vars should apply on that profile. This TS code snippet should be a good reference (that file generally should be a good reference).
Yes :)
The TOML data will contain the values of whatever configuration you provide it. |
|
@THardy98 after some refactoring, it looks like this: use Temporal\Client\ScheduleClient;
use Temporal\Client\WorkflowClient;
use Temporal\Common\EnvConfig\ConfigClient;
# load a client configuration (e.g. all profiles in a configuration) from TOML file and overridden by env vars if set
$profile = ConfigClient::load(env: $env); // ConfigProfile
# load a client configuration, but from provided TOML data and overridden by env vars if set
$profile = ConfigClient::load(profileName: 'my_profile', configFile: $pathOrData); // ConfigProfile
# convert a client configuration back to its TOML representation (as bytes)
$tomlConfig = ConfigClient::loadFromToml($pathOrData); // ConfigClient
$tomlData = $tomlConfig->toToml(); // string
# load a single profile
$profile = ConfigClient::load(profileName: 'my_profile'); // ConfigProfile
# load a profile and convert it into a representation that can be immediately used by client/connection
# (for a quick shorthand way to load and configure your client)
$profile = $profile = ConfigClient::load(); // ConfigProfile
$serviceClient = $profile->toServiceClient(); // ServiceClient
$clientOptions = $profile->toClientOptions(); // ClientOptions
$workflowClient = WorkflowClient::create($serviceClient, $clientOptions); // WorkflowClient
$scheduleClient = ScheduleClient::create($serviceClient, $clientOptions); // ScheduleClient |
THardy98
left a comment
There was a problem hiding this comment.
Generally LGTM - left a note about TLS interaction with API key
…n and array support
ConfigClient: rename `loadFromFile()` to `loadFromToml()`
… Windows in default config path resolving
What was changed
See the documentation below
Checklist
Documentation: External Client Configuration Support
Common docs: https://docs.temporal.io/develop/environment-configuration
The PHP SDK now implements the Temporal external client configuration specification, enabling standardized configuration management across development, staging, and production environments.
This feature allows you to:
internal/tomlpackage)Configuration File
Create a
temporal.tomlfile in your platform-specific configuration directory:~/.config/temporalio/temporal.toml(or$XDG_CONFIG_HOME/temporalio/temporal.toml)~/Library/Application Support/temporalio/temporal.toml%APPDATA%\temporalio\temporal.tomlLoading Configuration
The configuration system supports multiple loading strategies:
Environment Variables
All configuration keys can be overridden via environment variables using the
TEMPORAL_*prefix:Environment variables take precedence over configuration file values, enabling easy overrides for CI/CD pipelines and containerized deployments.
Configuration Hierarchy
Configuration is loaded with the following precedence (later values override earlier ones):
TEMPORAL_CONFIG_FILE)TEMPORAL_*variables)Default Profile Behavior
When loading a profile without explicitly specifying a name:
TEMPORAL_PROFILEis not set, the SDK looks for a profile named"default"profileNameparameter orTEMPORAL_PROFILEenv var) but doesn't exist, aProfileNotFoundExceptionis thrownProfile Management
Loading a Specific Profile
The
load()method returns a singleConfigProfileinstance:Working with Multiple Profiles
To access multiple profiles from a TOML file, use
loadFromToml():Loading Strategies
1. Load a single profile (recommended for most use cases):
2. Load from environment variables only:
3. Load all profiles from TOML (for multi-profile scenarios):
Remote Codec Support
Note
Remote codec configuration is not supported in the PHP SDK, following the same approach as TypeScript, Python, and .NET SDKs.
If you attempt to configure a remote codec either in the TOML file or via environment variables, the SDK will throw a
CodecNotSupportedExceptionto prevent silent failures:This explicit error ensures users are aware that codec functionality is not available, rather than silently ignoring the configuration and causing unexpected behavior.
Practical Usage Examples
Example 1: Quick Start - Load and Use a Profile
Example 2: Load Specific Profile from TOML
Example 3: Load from Environment Variables Only
Example 4: Working with Multiple Profiles (TOML Export/Import)
Example 5: Inline TOML Configuration