1

I'm currently in the process of releasing a Symfony bundle for a very small amount of people. This is the reason why I don't think will one day land on https://github.com/symfony/recipes-contrib, so I used the Flex Private Recipe documentation.

I pushed the bundle on GitHub and created another one to store its recipe.

This is my recipe:

{
  "manifests": {
    "edumedia/gar-api-bundle": {
      "manifest": {
        "bundles": {
          "eduMedia\\GarApiBundle\\eduMediaGarApiBundle": [
            "all"
          ]
        },
        "copy-from-recipe": {
          "config/": "%CONFIG_DIR%"
        },
        "env": {
          "GAR_DISTRIBUTOR_ID": "000000000_0000000000000000",
          "GAR_SSL_CERT": "/path/to/cert.pem",
          "GAR_SSL_KEY": "/path/to/cert.key"
        }
      },
      "ref": "ad610a54abdf2f5563841a4ce4b3c3cb29a7d0ff"
    }
  }
}

At the same level, there is a config directory that holds a configuration file:

# config/edumedia_gar_api.yaml
edumedia_gar_api:
  distributor_id: '%env(GAR_DISTRIBUTOR_ID)%'
  ssl_cert: '%env(GAR_SSL_CERT)%'
  ssl_key: '%env(GAR_SSL_KEY)%'
  remote_env: 'preprod'
  cache_directory: '%kernel.cache_dir%/gar-cache'

However, nothing is copied when executing the recipe.

yivi
  • 42,438
  • 18
  • 116
  • 138
Quentin
  • 183
  • 1
  • 15
  • Mmmh. Cannot reproduce. With [this](https://pastebin.com/96tNLNAR) `composer.json`, pointing to your bundle repo and recipe repo, the recipe is executed correctly: https://cln.sh/TUApUw. There are _other_ issues with your recipe (namely, your `copy-from-recipe` won't work as it is) – yivi Apr 06 '22 at 07:53
  • Oh! I thought the `extra.symfony.endpoint` was supposed to go in the bundle's `composer.json`, not the project's one. Adding it indeed allows the recipe to run. But as you said, the `copy-from-recipe` is ignored. Do you know why? I fail to understand where my default config YAML is supposed to be stored :( – Quentin Apr 06 '22 at 09:17
  • Ok, I'll edit the question so that's what it's asking, since the original issue about the location of `extra.symfony.endpoint` was resolved and was a simple confusion. – yivi Apr 06 '22 at 09:24

1 Answers1

3

On private recipes, files are not copied from the directory, but from the "recipe" itself.

The directory structure works when submitting a Flex recipe to the Symfony repository, but when creating a private recipe, the file's contents need to be inlined within the recipe's JSON.

E.g.:

{
  "manifests": {
    "edumedia/gar-api-bundle": {
      "manifest": {
        "bundles": {
          "eduMedia\\GarApiBundle\\eduMediaGarApiBundle": [
            "all"
          ]
        },
        "copy-from-recipe": {
          "config/": "%CONFIG_DIR%"
        },
        "env": {
          "GAR_DISTRIBUTOR_ID": "000000000_0000000000000000",
          "GAR_SSL_CERT": "/path/to/cert.pem",
          "GAR_SSL_KEY": "/path/to/cert.key"
        }
      },
      "files": {
                "config/packages/edumedia_gar_api.yaml": {
                    "contents": [
                        "edumedia_gar_api:",
                        "  distributor_id: '%env(GAR_DISTRIBUTOR_ID)%'",
                        "  ssl_cert: '%env(GAR_SSL_CERT)%'",
                        "  ssl_key: '%env(GAR_SSL_KEY)%'",
                        "  cache_directory: '%kernel.cache_dir%/gar-cache'",
                        "  remote_env: 'preprod'"
                    ],
                    "executable": false
                }
            },
      "ref": "ad610a54abdf2f5563841a4ce4b3c3cb29a7d0ff"
    }
  }
}

Creating this file by hand can be quite a chore. So it's usually better to create the recipe as if it was going to be a public recipe, with the complete directory structure (including a directory for vendor, package name, and version number), and use Symfony's tool to generate the finished recipe.

I describe that process on this other answer.

Quentin
  • 183
  • 1
  • 15
yivi
  • 42,438
  • 18
  • 116
  • 138