11How To Configure and Use Flex Private Recipe Repositories
22=========================================================
33
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.
77
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:
1310
1411* Create a private GitHub repository;
1512* Create your private recipes;
@@ -22,20 +19,21 @@ To do this, in broad strokes, you:
2219Create a Private GitHub Repository
2320----------------------------------
2421
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.
2826
2927Create Your Private Recipes
3028---------------------------
3129
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:
3331
3432.. code-block :: json
3533
3634 {
3735 "manifests" : {
38- "myorg /package-name" : {
36+ "acme /package-name" : {
3937 "manifest" : {
4038 },
4139 "ref" : " 7405f3af1312d1f9121afed4dddef636c6c7ff00"
@@ -49,10 +47,10 @@ If your package is a private Symfony bundle, you will have the following in the
4947
5048 {
5149 "manifests" : {
52- "myorg /private-bundle" : {
50+ "acme /private-bundle" : {
5351 "manifest" : {
5452 "bundles" : {
55- "Myorg \\ PrivateBundle\\ MyorgPrivateBundle " : [
53+ "Acme \\ PrivateBundle\\ AcmePrivateBundle " : [
5654 " all"
5755 ]
5856 }
@@ -62,43 +60,41 @@ If your package is a private Symfony bundle, you will have the following in the
6260 }
6361 }
6462
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.
7067
7168.. tip ::
7269
7370 Use the following PHP script to generate a random ``"ref" `` value.
7471
7572 .. code-block ::
7673
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));
8475
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" ``.
8679
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):
8883
89- Replace `` myorg `` and `` private-bundle `` with your own private bundle or package details.
84+ `` acme. private-bundle.1.0.json ``
9085
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:
9389
9490.. code-block :: json
9591
9692 {
9793 "manifests" : {
98- "myorg /private-bundle" : {
94+ "acme /private-bundle" : {
9995 "manifest" : {
10096 "bundles" : {
101- "Myorg \\ PrivateBundle\\ MyorgPrivateBundle " : [
97+ "Acme \\ PrivateBundle\\ AcmePrivateBundle " : [
10298 " all"
10399 ]
104100 },
@@ -107,9 +103,9 @@ project's ``/config/packages`` directory. To do that, change the recipe JSON fil
107103 }
108104 },
109105 "files" : {
110- "config/packages/myorg_private .yaml" : {
106+ "config/packages/acme_private .yaml" : {
111107 "contents" : [
112- " myorg_private :" ,
108+ " acme_private :" ,
113109 " encode: true" ,
114110 " "
115111 ],
@@ -121,21 +117,22 @@ project's ``/config/packages`` directory. To do that, change the recipe JSON fil
121117 }
122118 }
123119
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 `_.
125122
126123Create an Index to the Recipes
127124------------------------------
128125
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.
131128
132129The ``index.json `` file has the following format:
133130
134131.. code-block :: json
135132
136133 {
137134 "recipes" : {
138- "myorg /private-bundle" : [
135+ "acme /private-bundle" : [
139136 " 1.0"
140137 ]
141138 },
@@ -148,26 +145,24 @@ The ``index.json`` file has the following format:
148145 }
149146 }
150147
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.
154150
155151Store Your Recipes in the Private Repository
156152--------------------------------------------
157153
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.
160156
161157Grant ``composer `` Access to the Private Repository
162- -------------------------------------------------
158+ ---------------------------------------------------
163159
164160In your GitHub account, click your account icon in the top-right corner, select
165161``Settings `` and ``Developer Settings ``. Then select ``Personal Access Tokens ``.
166162
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:
171166
172167.. code-block :: terminal
173168
@@ -176,7 +171,7 @@ the following command:
176171 Replace ``[token] `` with the value of your GitHub personal access token.
177172
178173Configure Your Project's ``composer.json `` File
179- ---------------------------------------------
174+ -----------------------------------------------
180175
181176Add the following to your project's ``composer.json `` file:
182177
@@ -197,25 +192,27 @@ Replace ``your-github-account-name`` and ``your-recipes-repository`` with your o
197192
198193.. tip ::
199194
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.
202198
203199.. tip ::
204200
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``.
207203
208204Install the Recipes in Your Project
209205-----------------------------------
210206
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:
212209
213210.. code-block :: terminal
214211
215212 composer update
216213
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:
219216
220217.. code-block :: terminal
221218
0 commit comments