Skip to content

Conversation

@OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Dec 23, 2025

Why

In symfony/ai we basically have an "empty" ai.yaml file, as no stores are configured as default. When adding your first store you are not able to leverage the recipe otherwise.

cc @chr-hertel

Summary

This PR adds a create_if_missing option to the add-lines configurator. When using position: after_target, if the target is not found in the file, the content specified in create_if_missing will be appended to the file, followed by the regular content.

Example usage:

{
    "add-lines": [{
        "file": "config/packages/ai.yaml",
        "position": "after_target",
        "target": "    store:",
        "create_if_missing": "ai:\n    store:",
        "content": "        azuresearch:\n            default:\n                endpoint: '%env(AZURE_SEARCH_ENDPOINT)%'"
    }]
}

Behavior:

  • If store: exists → Content is added after it (existing behavior)
  • If store: doesn't exist but create_if_missing is set → The create_if_missing content is appended to the file, followed by the content
  • If store: doesn't exist and create_if_missing is not set → Warning is logged (existing behavior)

@OskarStark OskarStark changed the title Add create_if_missing option to add-lines configurator Add create_if_missing option to add-lines configurator Dec 23, 2025
@OskarStark OskarStark force-pushed the OskarStark/add-lines-create-if-missing branch from aea243b to 2eec7f6 Compare December 23, 2025 09:35
This option allows specifying YAML content that should be created
when the target is not found in the file. The content is appended
to the file followed by the regular content.

Example usage:
{
    "add-lines": [{
        "file": "config/packages/ai.yaml",
        "position": "after_target",
        "target": "    store:",
        "create_if_missing": "ai:\n    store:",
        "content": "        azuresearch:\n            ..."
    }]
}
@OskarStark OskarStark force-pushed the OskarStark/add-lines-create-if-missing branch from 2eec7f6 to 3a928f6 Compare December 23, 2025 09:38
@fabpot
Copy link
Member

fabpot commented Dec 24, 2025

We can maybe close this PR?

@stof
Copy link
Member

stof commented Dec 24, 2025

My proposal in symfony/recipes#1503 (comment) would make this PR unnecessary (adding one more advantage to the list)

@OskarStark OskarStark closed this Dec 24, 2025
@OskarStark OskarStark deleted the OskarStark/add-lines-create-if-missing branch December 24, 2025 11:18
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.

3 participants