Skip to content

[ComposerScriptsConfigurator] Auto-wire @auto-scripts into post-install-cmd and post-update-cmd#1089

Draft
wachterjohannes wants to merge 1 commit into
symfony:2.xfrom
wachterjohannes:auto-wire-auto-scripts
Draft

[ComposerScriptsConfigurator] Auto-wire @auto-scripts into post-install-cmd and post-update-cmd#1089
wachterjohannes wants to merge 1 commit into
symfony:2.xfrom
wachterjohannes:auto-wire-auto-scripts

Conversation

@wachterjohannes

@wachterjohannes wachterjohannes commented May 3, 2026

Copy link
Copy Markdown
Q A
Branch? 2.x
Bug fix? no
New feature? yes
Deprecations? no
Issues Prerequisite for symfony/ai#1994

When a recipe declares composer-scripts, Flex now also ensures @auto-scripts is wired into scripts.post-install-cmd and scripts.post-update-cmd in the user's composer.json. Restores parity with composer plugins for non-skeleton projects, where these hooks aren't pre-configured.

Cross-repo PRs

# Repo PR What Status
1 symfony/ai symfony/ai#2027 mate discover --ignore-missing-file open
2 symfony/ai symfony/ai#2026 Drop symfony/ai-mate-composer-plugin from symfony/ai-mate's require list (depends on symfony/ai#2027) draft
3 symfony/flex symfony/flex#1089 Auto-wire @auto-scripts into post-install-cmd / post-update-cmd this PR
4 symfony/recipes symfony/recipes#1535 The symfony/ai-mate recipe draft
5 symfony/ai follow-up Delete the composer plugin source not started

Summary

ComposerScriptsConfigurator::configure() now, in addition to merging into scripts.auto-scripts, ensures @auto-scripts is present in both post-install-cmd and post-update-cmd:

  • Hook missing → created as ["@auto-scripts"].
  • Hook is an array without @auto-scripts → appended.
  • Hook is a scalar → converted to array and appended.
  • Hook already contains @auto-scripts → no-op (idempotent).

unconfigure() is intentionally untouched — the wiring stays even when the package is uninstalled, because other recipes may depend on it.

Usage

Recipes can now declare composer-scripts and rely on the script running automatically in any project — including plain PHP projects without the Symfony skeleton's pre-wired hooks.

@wachterjohannes

Copy link
Copy Markdown
Author

Cross-references for the 4-PR plan in symfony/ai#1994:

chr-hertel added a commit to symfony/ai that referenced this pull request May 4, 2026
… command (wachterjohannes)

This PR was merged into the main branch.

Discussion
----------

[Mate] Add `--ignore-missing-file` option to `discover` command

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Docs?         | no
| Issues        | Fix #1994 (partial)
| License       | MIT

Adds an `--ignore-missing-file` option to `mate discover` that exits `0` as a no-op when `mate/extensions.php` does not exist. Required so the upcoming `symfony/ai-mate` Symfony Flex recipe can invoke `mate discover` unconditionally from Composer scripts.

## Cross-repo PRs

| # | Repo | PR | What | Status |
|---|---|---|---|---|
| 1 | symfony/ai | [#2027](#2027) | `mate discover --ignore-missing-file` | **this PR** |
| 2 | symfony/ai | [#2026](#2026) | Drop `symfony/ai-mate-composer-plugin` from `symfony/ai-mate`'s require list (depends on #2027) | draft |
| 3 | symfony/flex | [symfony/flex#1089](symfony/flex#1089) | Auto-wire ``@auto`-scripts` into `post-install-cmd` / `post-update-cmd` | draft |
| 4 | symfony/recipes | [symfony/recipes#1535](symfony/recipes#1535) | The `symfony/ai-mate` recipe | draft |
| 5 | symfony/ai | _follow-up_ | Delete the composer plugin source | not started |

## Summary

- Adds `--ignore-missing-file` option to `mate discover`: exits `0` when `mate/extensions.php` does not exist.

## Usage

The Flex recipe (symfony/recipes#1535) wires `vendor/bin/mate discover --composer --ignore-missing-file` into ``@auto`-scripts`, so it runs unconditionally on every `composer install` / `composer update` — including the first one, before `mate init` has been executed.

Commits
-------

439cabe [Mate] Add --ignore-missing-file option to discover command
@nicolas-grekas

Copy link
Copy Markdown
Member

Why is this needed to achieve your plan? Which non-skeleton apps is this meant to cover?

@wachterjohannes

Copy link
Copy Markdown
Author

@nicolas-grekas see the plan in symfony/ai#1994

this covers the integration of symfony mate - which will call the command vendor/bin/mate discover this allows to use mate in symfony apps with flex automatically add the script to composer.json post-*-cmd scripts or in none flex apps by calling the command manually or also add it manually to the composer.json

@wachterjohannes

Copy link
Copy Markdown
Author

@nicolas-grekas as soon as you are OK with the plan i can fix this PR - if you have any other idea which allows to acchieve the goal - i am open to change my plan :)

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.

2 participants