1
1
How To Configure and Use Flex Private Recipe Repositories
2
2
=========================================================
3
3
4
- Since the `release of version 1.16 `_ of ``symfony/flex ``, you can build your own private
5
- flex recipe repositories, and seamlessly integrate them into the `` composer `` package
6
- installation and maintenance process.
4
+ Since the `release of version 1.16 `_ of ``symfony/flex ``, you can build your own
5
+ private Symfony Flex recipe repositories, and seamlessly integrate them into the
6
+ `` composer `` package installation and maintenance process.
7
7
8
- This is particularly useful when you have private bundles or packages that must perform their own
9
- installation tasks, in a similar fashion that Symfony and other open-source bundles and packages handle their
10
- own installation tasks via ``symfony/flex ``.
11
-
12
- To do this, in broad strokes, you:
8
+ This is particularly useful when you have private bundles or packages that must
9
+ perform their own installation tasks. To do this, you need to complete several steps:
13
10
14
11
* Create a private GitHub repository;
15
12
* Create your private recipes;
@@ -22,20 +19,21 @@ To do this, in broad strokes, you:
22
19
Create a Private GitHub Repository
23
20
----------------------------------
24
21
25
- Log in to your GitHub.com account, click your account icon in the top-right corner, and select
26
- **Your Repositories **. Then click the **New ** button, fill in the **repository name **, select the
27
- **Private ** radio button, and click the **Create Repository ** button.
22
+ Log in to your GitHub.com account, click your account icon in the top-right
23
+ corner, and select **Your Repositories **. Then click the **New ** button, fill in
24
+ the **repository name **, select the **Private ** radio button, and click the
25
+ **Create Repository ** button.
28
26
29
27
Create Your Private Recipes
30
28
---------------------------
31
29
32
- A ``symfony/flex `` recipe is a standard JSON file that has the following structure:
30
+ A ``symfony/flex `` recipe is a JSON file that has the following structure:
33
31
34
32
.. code-block :: json
35
33
36
34
{
37
35
"manifests" : {
38
- "myorg /package-name" : {
36
+ "acme /package-name" : {
39
37
"manifest" : {
40
38
},
41
39
"ref" : " 7405f3af1312d1f9121afed4dddef636c6c7ff00"
@@ -49,10 +47,10 @@ If your package is a private Symfony bundle, you will have the following in the
49
47
50
48
{
51
49
"manifests" : {
52
- "myorg /private-bundle" : {
50
+ "acme /private-bundle" : {
53
51
"manifest" : {
54
52
"bundles" : {
55
- "Myorg \\ PrivateBundle\\ MyorgPrivateBundle " : [
53
+ "Acme \\ PrivateBundle\\ AcmePrivateBundle " : [
56
54
" all"
57
55
]
58
56
}
@@ -62,43 +60,41 @@ If your package is a private Symfony bundle, you will have the following in the
62
60
}
63
61
}
64
62
65
- Replace ``myorg `` and ``private-bundle `` with your own private bundle details.
66
-
67
- The ``"ref" `` entry is just a random 40-character string, which is used by ``composer `` to determine if
68
- your recipe was modified. Every time that you make changes to your recipe, you also need to
69
- generate a new ``"ref" `` value.
63
+ Replace ``acme `` and ``private-bundle `` with your own private bundle details.
64
+ The ``"ref" `` entry is a random 40-character string used by ``composer `` to
65
+ determine if your recipe was modified. Every time that you make changes to your
66
+ recipe, you also need to generate a new ``"ref" `` value.
70
67
71
68
.. tip ::
72
69
73
70
Use the following PHP script to generate a random ``"ref" `` value.
74
71
75
72
.. code-block ::
76
73
77
- $bytes = random_bytes(20);
78
- var_dump(bin2hex($bytes));
79
-
80
- The ``"all" `` entry tells ``symfony/flex `` to create an entry in your project's ``bundles.php `` file
81
- for all environments. To load your bundle only for the ``dev `` environment, replace ``"all" `` with ``"dev" ``.
82
-
83
- The name of your recipe JSON file must conform to the following convention:
74
+ echo bin2hex(random_bytes(20));
84
75
85
- ``myorg.private-bundle.1.0.json ``
76
+ The ``"all" `` entry tells ``symfony/flex `` to create an entry in your project's
77
+ ``bundles.php `` file for all environments. To load your bundle only for the
78
+ ``dev `` environment, replace ``"all" `` with ``"dev" ``.
86
79
87
- where ``1.0 `` is the version number of your bundle.
80
+ The name of your recipe JSON file must conform to the following convention,
81
+ where ``1.0 `` is the version number of your bundle (replace ``acme `` and
82
+ ``private-bundle `` with your own private bundle or package details):
88
83
89
- Replace `` myorg `` and `` private-bundle `` with your own private bundle or package details.
84
+ `` acme. private-bundle.1.0.json ``
90
85
91
- You will probably also want ``symfony/flex `` to create configuration files for your bundle or package in the
92
- project's ``/config/packages `` directory. To do that, change the recipe JSON file as follows:
86
+ You will probably also want ``symfony/flex `` to create configuration files for
87
+ your bundle or package in the project's ``/config/packages `` directory. To do
88
+ that, change the recipe JSON file as follows:
93
89
94
90
.. code-block :: json
95
91
96
92
{
97
93
"manifests" : {
98
- "myorg /private-bundle" : {
94
+ "acme /private-bundle" : {
99
95
"manifest" : {
100
96
"bundles" : {
101
- "Myorg \\ PrivateBundle\\ MyorgPrivateBundle " : [
97
+ "Acme \\ PrivateBundle\\ AcmePrivateBundle " : [
102
98
" all"
103
99
]
104
100
},
@@ -107,9 +103,9 @@ project's ``/config/packages`` directory. To do that, change the recipe JSON fil
107
103
}
108
104
},
109
105
"files" : {
110
- "config/packages/myorg_private .yaml" : {
106
+ "config/packages/acme_private .yaml" : {
111
107
"contents" : [
112
- " myorg_private :" ,
108
+ " acme_private :" ,
113
109
" encode: true" ,
114
110
" "
115
111
],
@@ -121,21 +117,22 @@ project's ``/config/packages`` directory. To do that, change the recipe JSON fil
121
117
}
122
118
}
123
119
124
- For more examples of what you can include in a recipe file, browse the live `Symfony recipe files `_.
120
+ For more examples of what you can include in a recipe file, browse the
121
+ `Symfony recipe files `_.
125
122
126
123
Create an Index to the Recipes
127
124
------------------------------
128
125
129
- The next step is to create an ``index.json `` file, which will contain entries for all your
130
- private recipes, and other general configuration information.
126
+ The next step is to create an ``index.json `` file, which will contain entries
127
+ for all your private recipes, and other general configuration information.
131
128
132
129
The ``index.json `` file has the following format:
133
130
134
131
.. code-block :: json
135
132
136
133
{
137
134
"recipes" : {
138
- "myorg /private-bundle" : [
135
+ "acme /private-bundle" : [
139
136
" 1.0"
140
137
]
141
138
},
@@ -148,26 +145,24 @@ The ``index.json`` file has the following format:
148
145
}
149
146
}
150
147
151
- Create an entry in ``"recipes" `` for each of your bundle recipes.
152
-
153
- Replace ``your-github-account-name `` and ``your-recipes-repository `` with your own details.
148
+ Create an entry in ``"recipes" `` for each of your bundle recipes. Replace
149
+ ``your-github-account-name `` and ``your-recipes-repository `` with your own details.
154
150
155
151
Store Your Recipes in the Private Repository
156
152
--------------------------------------------
157
153
158
- Upload the recipe ``.json `` file(s) and the ``index.json `` file into the root directory of your
159
- private GitHub repository.
154
+ Upload the recipe ``.json `` file(s) and the ``index.json `` file into the root
155
+ directory of your private GitHub repository.
160
156
161
157
Grant ``composer `` Access to the Private Repository
162
- -------------------------------------------------
158
+ ---------------------------------------------------
163
159
164
160
In your GitHub account, click your account icon in the top-right corner, select
165
161
``Settings `` and ``Developer Settings ``. Then select ``Personal Access Tokens ``.
166
162
167
- Generate a new access token with ``Full control of private repositories `` privileges.
168
-
169
- Copy the access token value, switch to the terminal of your local computer, and execute
170
- the following command:
163
+ Generate a new access token with ``Full control of private repositories ``
164
+ privileges. Copy the access token value, switch to the terminal of your local
165
+ computer, and execute the following command:
171
166
172
167
.. code-block :: terminal
173
168
@@ -176,7 +171,7 @@ the following command:
176
171
Replace ``[token] `` with the value of your GitHub personal access token.
177
172
178
173
Configure Your Project's ``composer.json `` File
179
- ---------------------------------------------
174
+ -----------------------------------------------
180
175
181
176
Add the following to your project's ``composer.json `` file:
182
177
@@ -197,25 +192,27 @@ Replace ``your-github-account-name`` and ``your-recipes-repository`` with your o
197
192
198
193
.. tip ::
199
194
200
- The ``extra.symfony `` key will most probably already exist in your ``composer.json ``. Simply
201
- add the ``"endpoint" `` key to the existing ``extra.symfony `` entry.
195
+ The ``extra.symfony `` key will most probably already exist in your
196
+ ``composer.json ``. In that case, add the ``"endpoint" `` key to the existing
197
+ ``extra.symfony `` entry.
202
198
203
199
.. tip ::
204
200
205
- The ``endpoint `` URL **must ** point to ``https://api.github.com/repos `` and ** not* to
206
- ``https://www.github.com``. The latter will not work .
201
+ The ``endpoint `` URL **must ** point to ``https://api.github.com/repos `` and
202
+ ** not* to ``https://www.github.com``.
207
203
208
204
Install the Recipes in Your Project
209
205
-----------------------------------
210
206
211
- If your private bundles / packages have not yet been installed in your project, run the following command:
207
+ If your private bundles/packages have not yet been installed in your project,
208
+ run the following command:
212
209
213
210
.. code-block :: terminal
214
211
215
212
composer update
216
213
217
- If the private bundles / packages have already been installed and you just want to install the new
218
- private recipes, run the following command:
214
+ If the private bundles/ packages have already been installed and you just want to
215
+ install the new private recipes, run the following command:
219
216
220
217
.. code-block :: terminal
221
218
0 commit comments