OpenAPITools / OpenAPITools/openapi-generator

[REQ] Generate PHP client code during Composer installation of a program

Open
#13,614 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

The generated PHP code is a complete Composer package that must be stored and published separately for new versions of the code generator. You cannot generate the client code during program installation with Composer.

Describe the solution you'd like

A way to keep generated code out of source control and have it generated when running composer install in the application that needs the client.

Describe alternatives you've considered

As a solution I created a package with the minimum set of files to run the generator, like JAR file, API definition and generator configurations file. It also has a PHP program that executes the generator and can delete all the generated code. This program accepts a string with the folder to put the generated code in.

In the main application a Composer script was added that is triggered at the event to generate the autoloader. The included PHP program is called to generate the client code and put it at the appropriate location in the source tree. A second script is triggered when the package is uninstalled. It removes previously generated code.

The problem is that the package dependencies in the generated code are not included in the main program. For now I manually added those dependencies to the main program. When updating the generator a manual check must be done to keep those dependencies in sync.

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how the generator's JAR, API definition, and generator configuration are packaged and how Composer install and autoloader events run PHP scripts. Trace the existing dependency declarations in generated PHP code. Done means an application can generate the client during Composer installation without committing generated code or manually duplicating its dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, php
Domain
api, build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.