Skip to content

Commit 98d40ed

Browse files
committed
Development
1 parent 8127feb commit 98d40ed

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

7. Development.md

+191
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,203 @@
22

33
#### 7.1 Demonstrate ability to change configurations
44

5+
###### What are the sources of Magento configuration, and which priorities have different sources of Magento configuration?
6+
7+
All system configurations are set during deployment according to the following override scheme:
8+
9+
1. If an environment variable exists, use the custom configuration and ignore the default configuration.
10+
2. If an environment variable does not exist, use the configuration from a `MAGENTO_CLOUD_RELATIONSHIPS` name-value pair in the `.magento.app.yaml` file. Ignore the default configuration.
11+
3. If an environment variable does not exist and `MAGENTO_CLOUD_RELATIONSHIPS` does not contain a name-value pair, remove all customized configuration and use the values from the default configuration.
12+
13+
14+
The general format of system settings variable names follows:`<SCOPE>__<SYSTEM__VARIABLE__NAME>`
15+
16+
`<SCOPE>` can be either:
17+
- Global scope (that is, the global setting for all scopes)
18+
Global scope variables have the following format: `CONFIG__DEFAULT__<SYSTEM__VARIABLE__NAME>`
19+
- A specific scope (that is, the setting affects only a specified store view or website)
20+
Store view scope variables, for example, have the following format: `CONFIG__STORES__ <STORE_VIEW_CODE>__<SYSTEM__VARIABLE__NAME>`
21+
22+
`<SYSTEM__VARIABLE__NAME>` is derived from a configuration setting’s configuration path, which is a / delimited string that uniquely identifies a particular setting.
23+
Replace each / character in the configuration path with two underscore characters to create the system variable.
24+
25+
Example:
26+
```yaml
27+
variables:
28+
env:
29+
CONFIG__DEFAULT__PAYPAL_ONBOARDING__MIDDLEMAN_DOMAIN: 'payment-broker.magento.com'
30+
CONFIG__STORES__DEFAULT__PAYMENT__BRAINTREE__CHANNEL: 'Magento_Enterprise_Cloud_BT'
31+
CONFIG__STORES__DEFAULT__PAYPAL__NOTATION_CODE: 'Magento_Enterprise_Cloud'
32+
```
33+
34+
[Use environment variables to override configuration settings](https://devdocs.magento.com/guides/v2.2/config-guide/prod/config-reference-var-name.html)
35+
536
#### 7.2 Demonstrate ability to change a locale
637
38+
###### Know how to change a locale on Cloud
39+
40+
> Any data that exports to the file becomes locked.
41+
> The corresponding field in the Magento Admin becomes read-only.
42+
> This ensures consistent configurations as you push the file across all environments. And every time you run this command, any new configurations are appended to your config.php file.
43+
> If you need to modify or delete an existing configuration, you must edit the file manually.
44+
45+
update `app/etc/config.php` file, commit and push to Git.
46+
47+
[Example of managing system-specific settings](https://devdocs.magento.com/guides/v2.3/cloud/live/sens-data-initial.html)
48+
749
#### 7.3 Demonstrate ability to add extensions
850

51+
###### Know how to install Magento extensions and themes (limitations, read-only filesystem, etc.)
52+
53+
- Install module: `composer require <component-name>:<version>`
54+
> When adding the module to composer.json, the file app/etc/config.php will also be updated.
55+
> This file includes a list of installed modules, themes, and language packages, shared configuration settings.
56+
- Verify the extension: `php bin/magento module:status`
57+
- Commit and push changes:
58+
```bash
59+
git add -A
60+
git commit -m "<message>"
61+
git push magento <environment ID>
62+
```
63+
64+
[Install, manage, and upgrade extensions](https://devdocs.magento.com/guides/v2.3/cloud/howtos/install-components.html)
65+
966
#### 7.4 Demonstrate ability to enable / disable a module
1067

68+
###### Know how to enable or disable a module on Cloud
69+
70+
Enable a module. This command updates the config.php file with the enabled status of the module.
71+
`php bin/magento module:enable <module name>`
72+
73+
Disable a module. This command updates the config.php file with the disable status of the module.
74+
`php bin/magento module:disable <module name>`
75+
76+
Commit `app/etc/config.php` file and push to Git.
77+
1178
#### 7.5 Demonstrate ability to set up a multisite configuration
1279

80+
###### Know how to setup multisite configuration: Adding and configuring new websites in Magento; Nginx configuration through the .magento.app.yaml for multisite setup; how to route websites through the magento-vars.php
81+
82+
- Configure routes in `.magento/routes.yaml`
83+
84+
> For Pro, you must create a Support ticket to set up routes in the Staging or Production environment.
85+
86+
```yaml
87+
"http://{default}/":
88+
type: upstream
89+
upstream: "mymagento:php"
90+
91+
"https://{default}/":
92+
type: upstream
93+
upstream: "mymagento:php"
94+
95+
"http://*.{default}/":
96+
type: upstream
97+
upstream: "mymagento:php"
98+
99+
"https://*.{default}/":
100+
type: upstream
101+
upstream: "mymagento:php"
102+
```
103+
104+
- Set up websites, stores, and store views
105+
[Set up multiple websites, stores, and store views in the Admin](https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_websites.html)
106+
107+
108+
- Modify the `magento-vars.php` file
109+
> Instead of configuring an NGINX virtual host, pass the MAGE_RUN_CODE and MAGE_RUN_TYPE variables using the magento-vars.php file located in your project root directory.
110+
111+
112+
```php
113+
<?php
114+
// default magento-vars.php from magento cloud repo
115+
// enable, adjust and copy this code for each store you run
116+
// Store #0, default one
117+
//if (isHttpHost("example.com")) {
118+
// $_SERVER["MAGE_RUN_CODE"] = "default";
119+
// $_SERVER["MAGE_RUN_TYPE"] = "store"; // website
120+
//}
121+
function isHttpHost($host)
122+
{
123+
if (!isset($_SERVER['HTTP_HOST'])) {
124+
return false;
125+
}
126+
return strpos(str_replace('---', '.', $_SERVER['HTTP_HOST']), $host) === 0;
127+
}
128+
```
129+
130+
Example:
131+
```php
132+
<?php
133+
// enable, adjust and copy this code for each store you run
134+
// Store #0, default one
135+
function isHttpHost($host)
136+
{
137+
if (!isset($_SERVER['HTTP_HOST'])) {
138+
return false;
139+
}
140+
return $_SERVER['HTTP_HOST'] === $host;
141+
}
142+
if (isHttpHost("french.branch-sbg7pPa-f3dueAiM03tpy.us.magentosite.cloud"))
143+
{
144+
$_SERVER["MAGE_RUN_CODE"] = "french";
145+
$_SERVER["MAGE_RUN_TYPE"] = "website";
146+
}
147+
```
148+
149+
After deployment, open your site base URL in a web browser.
150+
151+
Use the format: http://<magento-run-code>.<site-URL>
152+
For example, http://french.master-name-projectID.us.magentosite.cloud/
153+
154+
[Set up multiple websites or stores](https://devdocs.magento.com/guides/v2.3/cloud/project/project-multi-sites.html)
155+
13156
#### 7.6 Demonstrate ability to use variables
157+
158+
###### When do you need to use variables; which configurations you can change using variables
159+
160+
[Cloud variables](https://devdocs.magento.com/guides/v2.3/cloud/env/variables-cloud.html)
161+
[ADMIN variables](https://devdocs.magento.com/guides/v2.3/cloud/env/environment-vars_magento.html)
162+
163+
example:
164+
- ADMIN_USERNAME
165+
- ADMIN_EMAIL
166+
- ADMIN_PASSWORD
167+
- ADMIN_LOCALE
168+
- ADMIN_URL
169+
- CRON_CONSUMERS_RUNNER
170+
- CRYPT_KEY
171+
- UPDATE_URLS
172+
173+
Note: it's possible to override values from `.magento.env.yaml` from deploy stage.
174+
see:
175+
- [Config\Stage\Deploy::get](https://github.com/magento/ece-tools/blob/develop/src/Config/Stage/Deploy.php#L47)
176+
- [Config\Stage\Deploy\MergedConfig::get](https://github.com/magento/ece-tools/blob/develop/src/Config/Stage/Deploy/MergedConfig.php#L69)
177+
- [Config\Stage\Deploy\EnvironmentConfig::getAll](https://github.com/magento/ece-tools/blob/develop/src/Config/Stage/Deploy/EnvironmentConfig.php)
178+
179+
###### What is the difference between variables and environment variables
180+
181+
Variables from `MAGENTO_CLOUD_VARIABLES` (base64 encoded json) env variable (common variable in admin panel)
182+
Environment variables have prefix `env:` in admin panel
183+
> When attempting to use environment variables to override configuration settings using the Project Web Interface, you must prepend the variable name with env: as in the following example.
184+
![env-variable](https://devdocs.magento.com/common/images/cloud_env_var_example.png)
185+
186+
###### What is the difference between project and environment level variables
187+
188+
**Project-specific variables**
189+
To set the same value for all environments in your project, use the magento-cloud project:variable:set command.
190+
These variables are available at build and runtime in all environments.
191+
192+
**Environment-specific variables**
193+
To set a unique value for a specific environment, use the magento-cloud variable:set command. These variables are available at runtime and are inherited by child environments.
194+
You should specify the environment in your command using the -e option.
195+
196+
197+
- [Working with variables](https://devdocs.magento.com/guides/v2.3/cloud/env/working-with-variables.html)
198+
199+
Documentation:
200+
- [Configuration management for store settings](https://devdocs.magento.com/guides/v2.3/cloud/live/sens-data-over.html)
201+
- [Working with variables](https://devdocs.magento.com/guides/v2.3/cloud/env/working-with-variables.html)
202+
- [Set up multiple websites, stores, and store views in the Admin](https://devdocs.magento.com/guides/v2.3/config-guide/multi-site/ms_websites.html)
203+
- [Install, manage, and upgrade extensions](https://devdocs.magento.com/guides/v2.3/cloud/howtos/install-components.html)
204+
- [Use environment variables to override configuration settings](https://devdocs.magento.com/guides/v2.2/config-guide/prod/config-reference-var-name.html)

0 commit comments

Comments
 (0)