Skip to content

feat(internal/librarian/php): install tools using composer - #6799

Merged
sofisl merged 19 commits into
googleapis:mainfrom
sofisl:php-install-step1-alt
Jul 15, 2026
Merged

sofisl merged 19 commits into
googleapis:mainfrom
sofisl:php-install-step1-alt

Conversation

@sofisl

@sofisl sofisl commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds the ability to iterate over tools.Composer from librarian.yaml for dynamic PHP tool installation. Also adds a pip installation that we'll need for the post-processor (synthtool). Retains the original installGenerator function as a fallback for workflows without librarian.yaml.

For #6630

Adds the ability to iterate over tools.Composer from librarian.yaml
for dynamic PHP tool installation. Retains the original installGenerator
function as a fallback for workflows without librarian.yaml.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for installing Composer tools in the PHP generator tool installation process. It introduces a new helper function repoFromPackageURL to extract repository paths from GitHub archive URLs, along with corresponding unit tests. The review feedback suggests placing the %w specifier at the front of the formatted error message when wrapping the sentinel error errMissingPackageURL in install.go. Additionally, it recommends simplifying the unit tests in install_test.go by avoiding table-driven tests since they only contain a single test case.

Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install_test.go Resolved
Comment thread internal/librarian/php/install_test.go Resolved
@sofisl
sofisl marked this pull request as ready for review July 13, 2026 21:47
@sofisl
sofisl requested a review from a team as a code owner July 13, 2026 21:47
@sofisl sofisl changed the title feat(php): support dynamic composer installation feat(php): install tools using composer Jul 13, 2026
@sofisl sofisl changed the title feat(php): install tools using composer feat(internal/librarian/php): install tools using composer Jul 13, 2026
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install_test.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install_test.go Resolved

@JoeWang1127 JoeWang1127 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need more refactor on Install function but this is fine for the first iteration.

Some potential refactor:

  1. extract composer install to a separate package to internal/tool/composer or internal/tool/php.
  2. verify a tool before installation, can also happen in composer/php package.

@sofisl sofisl mentioned this pull request Jul 14, 2026
Comment thread internal/librarian/php/generate.go Resolved
Comment thread tool/cmd/migrate/php.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread tool/cmd/migrate/php.go Resolved
Comment thread internal/librarian/php/install.go Resolved
Comment thread internal/librarian/php/install.go Resolved
…ormation for Composer tools

The gapic-generator-php tool is not available on Packagist, meaning
it cannot be fetched natively via composer using a URL. It must always
be downloaded from source via fetch.Repo.

Because of this, configuring the ComposerTool Package field as an archive
URL to then perform string transformations via repoFromPackageURL was
unnecessary. This change updates the configuration schema to directly
specify the GitHub repository path for ComposerTools instead, avoiding the
redundant string transformations entirely.
Comment thread internal/config/config.go Resolved
Comment thread internal/librarian/php/install.go Resolved
sofisl and others added 5 commits July 15, 2026 19:43
The ComposerTool configuration field was previously named 'Package'.
This name caused confusion because composer does not support installing
from an arbitrary tarball URL like some other package managers do. We
actually parse this string as a GitHub repository. Renaming this field
to 'Repo' avoids this confusion.

Additionally, renamed errMissingPackageURL to errMissingRepo with the message
'repo URL missing' based on reviewer feedback.
Updates the embedded librarian_php.yaml configuration template to use
the newly renamed 'repo' field and string instead of the deprecated
'package' archive URL, fixing test failures after the recent rebase/pull.

Also updates the migrate test expectation to account for the build script.
Since the Composer installation logic internally hardcodes 'composer install',
the Build field is redundant. This removes it from the struct schema and the
embedded migration template, as well as test expectations.
@sofisl
sofisl merged commit 482238f into googleapis:main Jul 15, 2026
32 checks passed
yangyzs pushed a commit that referenced this pull request Jul 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.27.0](v0.26.0...v0.27.0)
(2026-07-17)


### Features

* **internal/config:** add additional_protos configuration support for
php ([#6801](#6801))
([26c1029](26c1029)),
closes [#6743](#6743)
* **internal/librarian/golang:** support protoc tool configuration
([#6767](#6767))
([7013350](7013350))
* **internal/librarian/java:** populate RequiresBilling from API config
in README template
([#6737](#6737))
([da3bc04](da3bc04))
* **internal/librarian/java:** pre-validate java libraries bom version
in config ([#6674](#6674))
([620a505](620a505))
* **internal/librarian/nodejs:** support src_dir for pnpm tool
sourcebuilds
([#6877](#6877))
([c58e52d](c58e52d))
* **internal/librarian/php:** add tidying logic for additional_protos
([#6819](#6819))
([ec61444](ec61444)),
closes [#6743](#6743)
* **internal/librarian/php:** install tools using composer
([#6799](#6799))
([482238f](482238f))
* **internal/librarian/php:** integrate additional_protos into client
generation
([#6810](#6810))
([51bfdd2](51bfdd2)),
closes [#6743](#6743)
* **internal/librarian/php:** make CommonResources configurable for php
([#6823](#6823))
([f30d232](f30d232)),
closes [#6813](#6813)
* **internal/librarian/php:** run owlbot.py in generate phase
([#6869](#6869))
([2d4b208](2d4b208)),
closes [#6773](#6773)
* **internal/librarian/php:** support install PNPM tools
([#6839](#6839))
([192e469](192e469)),
closes [#6830](#6830)
* **librarian:** config get libraries apiPath
([#6655](#6655))
([e5cd774](e5cd774))
* **sidekick/rust:** generate LRO `Poller` for bigquery `InsertJob`
([#6841](#6841))
([d5ce8a9](d5ce8a9))
* **sidekick/swift:** `oneof` in method signatures
([#6863](#6863))
([9ebd4bc](9ebd4bc))
* **sidekick/swift:** generate core package versions
([#6812](#6812))
([1a08672](1a08672)),
closes [#5940](#5940)
* **sidekick/swift:** generate telemetry headers
([#6820](#6820))
([b24d086](b24d086))
* **sidekick/swift:** use `$apiVersion`
([#6794](#6794))
([0b309b8](0b309b8))
* **sidekick/swift:** use internal import over @_implementationOnly
([#6817](#6817))
([096d91c](096d91c))
* **swift:** add convert-swift functionality
([#6802](#6802))
([7813442](7813442))
* **swift:** format all module output directories
([#6840](#6840))
([eb684c9](eb684c9))
* **too/cmd/migrate:** specify protoc version in tools section
([#6793](#6793))
([201fa99](201fa99)),
closes [#6791](#6791)
* **tool/cmd/migrate:** add prettier formatting tools to PHP migration
template ([#6831](#6831))
([9c06b20](9c06b20))
* **tool/cmd/migrate:** discover ruby libraries during migration
([#6856](#6856))
([fefcc0e](fefcc0e)),
closes [#6632](#6632)
* **tool/cmd/migrate:** parse BUILD.bazel and populate AdditionalProtos
for php ([#6814](#6814))
([53e3f4b](53e3f4b)),
closes [#6743](#6743)
* **tool/cmd/migrate:** set php default for common_resources
([#6836](#6836))
([b2df615](b2df615)),
closes [#6813](#6813)


### Bug Fixes

* **.github:** restore pnpm version
([#6851](#6851))
([0735cac](0735cac))
* **internal/config:** remove PHPPackage.AdditionalProtos and simplify
logic ([#6818](#6818))
([19c4a93](19c4a93)),
closes [#6743](#6743)
* **internal/librarian/nodejs:** fallback to Checksum if SHA256 is empty
([#6804](#6804))
([cf906e6](cf906e6)),
closes [#6803](#6803)
* **internal/librarian/nodejs:** pass --no-comments to compileProtos
([#6866](#6866))
([e749b3e](e749b3e))
* **sidekick/swift:** clashes for `Logging`
([#6878](#6878))
([faf0c22](faf0c22))
* **sidekick/swift:** dependencies on `Clients.swift`
([#6864](#6864))
([c5bca34](c5bca34))
* **sidekick/swift:** no escaping for `GateExpression`
([#6829](#6829))
([b26b680](b26b680))
* **sidekick/swift:** skip external package traits
([#6848](#6848))
([ba9041c](ba9041c))
* **tool/cmd/migrate:** add SHA256 for protoc version in php migrate
([#6798](#6798))
([0a47b2f](0a47b2f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants