Repository navigation
Conversation
PHP codegen asks Query.formatIdentifiers for the schema's names (or reads them from --names-file) and names classes PASCAL/CAPITALIZED (PSR-1: Llm, SdkConfig), methods and parameters CAMEL/CAPITALIZED (withGpu, insecureSkipTlsVerify) and enum cases SCREAMING_SNAKE (PER_SESSION). Schemas without formatIdentifiers keep the legacy conversion and generate the same code. Wire names never change. Compatibility for existing code: - classes renamed only in letter case still resolve (PHP class names are case-insensitive); the LegacyClassNames autoloader finds their file on case-sensitive filesystems, with a deprecation notice; - a #[GraphQLType] attribute names the GraphQL type of a class spelled differently, used by loadObjectFromId and the module entrypoint; - methods renamed beyond letter case keep a deprecated forwarder; - renamed enum cases keep a deprecated constant under the old name. Signed-off-by: Alex Suraci <[email protected]>
Regenerate the PHP client against a schema with Query.formatIdentifiers: classes like LLM become Llm (old spellings keep loading), methods like withGPU become withGpu, and enum cases like EStarGZ become E_STAR_GZ with a deprecated constant for the old name. Signed-off-by: Alex Suraci <[email protected]>
The PHP codegen exec has no engine session, so the runtime formats the module schema's names with Query.formatIdentifiers (with the schema's own version's dictionary) and hands them to codegen as a --names-file sidecar. Schemas without formatIdentifiers get no file, keeping the legacy names. Bump the runtime module to engineVersion v1.0.0 for the API. Signed-off-by: Alex Suraci <[email protected]>
This was referenced Oct 14, 2026
Contributor
Author
|
🤖 Closing: the in-repo SDKs are now legacy. This work will be redone as a PR against github.com/dagger/php-sdk ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 5f/N of the stack splitting #14501 (identifier casing): the PHP SDK. Plan: #14501 (comment)
Refs #13668
Stacked on #14673.
What changes for PHP
When the schema has
Query.formatIdentifiers(engine views v1.0.0 and later), PHP codegen asks the engine to format every schema name and uses the result. On schemas without it, codegen keeps its legacy conversion and the output doesn't change.LLM,SDKConfig,HTTPStateLLM,SDKConfig,HTTPStateLlm,SdkConfig,HttpStatePASCAL:CAPITALIZED(PSR-1)withGPU,traceURLwithGPU(),traceURL()withGpu(),traceUrl()CAMEL:CAPITALIZEDinsecureSkipTLSVerify$insecureSkipTLSVerify$insecureSkipTlsVerifyCAMEL:CAPITALIZEDEStarGZ,OCIMediaTypescase EStarGZcase E_STAR_GZSCREAMING_SNAKE:UPPERCASEOnly PHP identifiers change. Field names, argument names, input object fields, enum values and GraphQL type names on the wire are exactly what the schema has. For example,
case E_STAR_GZ = 'EStarGZ'. Input object properties keep the schema's spelling because they are sent under their own name.Old spellings keep working
\Dagger\LLMstill names\Dagger\Llm. PSR-4 autoloading would look forLLM.php, which a case-sensitive filesystem won't find. TheLegacyClassNamesautoloader (registered from composerfiles, after Composer's) finds the generated file ignoring case and emitsE_USER_DEPRECATED.withGPU()still callswithGpu(). A method renamed beyond letter case gets a deprecated forwarder under the old name.public const EStarGZ = self::E_STAR_GZ;. A value whose formatted name would collide with another value keeps its schema name (Gzipnext toGZIP).#[GraphQLType('LLM')]: this attribute is generated on classes whose PHP name differs from their GraphQL type.AbstractClient::loadObjectFromIdand the module entrypoint (EntrypointCommand, throughNormalizesClassName::graphQLTypeName) read it, so a function returningLlmregisters asLLM. Without the attribute, the old name-based guess applies.What's in it
src/Codegen):SchemaGeneratorcallsformatIdentifiersin batches. The three formats areNewCodegenVisitor::NAME_FORMATS.dagger:codegen --schema-filetakes--names-file, the sidecar format ofcodegen introspect --names-out(FormattedNames).sdk/php/runtime): the codegen exec has no engine session, so the runtime formats the module schema's names itself (internal/names, usingformatIdentifierswith the schema's__schemaVersiondictionary). It mounts them as--names-file. A schema without the API gets no file. The runtime module is bumped toengineVersion: v1.0.0, and its bindings now come from v1 views (nullable object returns,PhpSDK/introspectionJSONmodule names from core: name modules with engine/naming from v1.0.0-beta.21 #14669).sdk/php/generated):LLM*.phpare renamed toLlm*.php, along withSdkConfig,HttpStateandWorkspaceSdk, plus the method, parameter and enum case renames above.Not in it
callID,shortSHA,FunctionCachePolicyDEFAULT/…) and the PHP "old schema names" table (RenamedCoreNames,AbstractInputObject::FIELD_NAMES). Without that table, regenerating after PR 6 would drop the old names of renamed input fields and enum values, so it belongs with PR 6.sdk/php/runtime/internal/dagger/*.gen.goare taken from the final tree, not regenerated here. No generator covers them, and regenerating with the current Go codegen also moves them to the newinternal/dagger/core/layout, which is unrelated churn. Go modules regenerate their bindings at load anyway.go vetandgo testpass.Breaking changes for PHP SDK users
These only apply to code generated against a v1 schema: the client, or a module declaring
engineVersion≥ v1.0.0-0. Older modules generate exactly as before.$ctr->from('alpine', insecureSkipTLSVerify: true)must becomeinsecureSkipTlsVerify: true, because PHP parameter names are case-sensitive. Positional calls are unaffected. PHP has no way to alias a parameter name. This is the main hard break.ImageMediaTypes::OCIMediaTypesstill works as a deprecated constant, but->nameis nowOCI_MEDIA_TYPES. Code that compares->name, or lists::cases(), sees the new names.->valueand::from()are unchanged.get_class($llm)returnsDagger\Llm, and$x instanceof \Dagger\LLMstill works, since PHP matches class names case-insensitively. A string comparison against'Dagger\LLM', or amatchon the class name, does not.LegacyClassNames, which Composer'sfilesautoload registers.E_USER_DEPRECATED. This only matters where deprecations are turned into exceptions, e.g. in PHPUnit strict modes.How long these deprecated spellings live is an open decision (proposed: through 1.0).
Testing
php-clientchecks:test(PHPUnit, including new tests forFormattedNames,SchemaGenerator, the visitor's names/forwarders/enum constants/#[GraphQLType],LegacyClassNames,NormalizesClassNameandAbstractClient),php-stan,php-code-snifferandapi/stale, all on the rebased branch.Runtime:
go vet ./...andgo test ./internal/names/.Integration:
TestPHP, 27 tests, passing. The fixture modules declare old engine versions, so this covers the legacy fallback path.Manual QA against a dev engine with a PHP module on
engineVersion: v1.0.0:ImageMediaTypes::OCI_MEDIA_TYPEScase exists, andOCIMediaTypesresolves through the deprecated constant;\Dagger\LLMMessageRole::USERloads viaLegacyClassNames;withGPU()andwithGpu()both work;LlmMessageRoleregisters asLLMMessageRole.Returning a core enum value from a PHP function fails with
cannot create enum name from map. That also happens with an unrenamed enum (NetworkProtocol), so it predates this PR.