From d6ef73d65ab260e3841315119eca0c761c1cc196 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Mon, 14 Sep 2026 13:54:37 -0400 Subject: [PATCH] [php-nextgen] Respect `composerPackageName` Config Option --- .../codegen/languages/AbstractPhpCodegen.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java index 7051fcea4f87..04c784f975c1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java @@ -65,6 +65,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg @Setter protected String developerOrganizationUrl = "https://openapi-generator.tech"; @Setter protected String srcBasePath = "lib"; @Setter protected String testBasePath = "test"; + @Setter protected String composerPackageName = null; protected String docsBasePath = "docs"; protected String apiDirName = "Api"; protected String modelDirName = "Model"; @@ -332,6 +333,10 @@ public void processOpts() { this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID)); } + if (additionalProperties.containsKey(CodegenConstants.COMPOSER_PACKAGE_NAME)) { + this.setComposerPackageName((String) additionalProperties.get(CodegenConstants.COMPOSER_PACKAGE_NAME)); + } + if (!this.getComposerPackageName().isEmpty()) { additionalProperties.put("composerPackageName", this.getComposerPackageName()); } @@ -1038,11 +1043,15 @@ public void postProcessFile(File file, String fileType) { } /** - * Get Composer package name based on GIT_USER_ID and GIT_REPO_ID. + * Get Composer package name. Returns the explicitly configured value if set, otherwise + * derives it from GIT_USER_ID and GIT_REPO_ID. * * @return package name or empty string on fail */ public String getComposerPackageName() { + if (this.composerPackageName != null && !this.composerPackageName.isEmpty()) { + return this.composerPackageName; + } String packageName = this.getGitUserId() + "/" + this.getGitRepoId(); if ( packageName.contentEquals("/")