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.
CodePudding user response:
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.