From 295f3cf02baa50139eff4b122d48dcddfab1ab9f Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Tue, 26 Sep 2023 12:07:01 +0200 Subject: [PATCH 1/2] :pencil: Added a few sections for the env.php --- basic-configuration.md | 192 +++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 115 deletions(-) diff --git a/basic-configuration.md b/basic-configuration.md index ba66ec2..25cf1e9 100644 --- a/basic-configuration.md +++ b/basic-configuration.md @@ -1,121 +1,83 @@ -# Basic Configuration Documentation +# Basic Configuration [TOC] -This document provides instructions on how to perform basic configuration in Magento 2. Magento 2 is a powerful -e-commerce platform built on PHP, and understanding how to configure it is essential for creating a successful online -store. In this guide, we will cover the most important configuration settings and provide concrete examples and code -snippets to help you understand and implement them. +## Introduction + +Magento 2, a versatile eCommerce platform, offers extensive configurability to meet the needs of developers. This +document discusses the fundamental configuration in Magento 2, focusing on `app/etc/env.php`, `app/etc/config.php`, +`core_config_data` table, `config.xml`, and managing configuration programmatically. + +## Environment Configuration in `app/etc/env.php` + +The `app/etc/env.php` file is pivotal for environment-specific configurations. It stores settings such as database +connection information, backend front name, cryptographic key, and more. + +### Database Connection + +The `db` section in `app/etc/env.php` contains the database connection information. It is used by Magento to connect to +the database. The following snippet shows the default database connection settings: + +```php +// app/etc/env.php +return [ + // ... + 'db' => [ + 'connection' => [ + 'default' => [ + 'host' => 'YOUR_DATABASE_HOST', + 'dbname' => 'YOUR_DATABASE_NAME', + 'username' => 'YOUR_DATABASE_USER', + 'password' => 'YOUR_DATABASE_PASSWORD', + 'model' => 'mysql4', + 'engine' => 'innodb', + 'initStatements' => 'SET NAMES utf8;', + 'active' => '1', + 'driver_options' => [ + // Add your PDO driver options here. @see https://www.php.net/manual/en/ref.pdo-mysql.php + ] + ] + ], + 'table_prefix' => '' // Add a table prefix here if you are sharing this database with other applications. Not recommended... + ], + // ... +]; +``` + +### Backend Front Name + +The `backend` section in `app/etc/env.php` contains the backend front name. It is used by Magento to access the backend +area. The following snippet shows the default backend front name: + +```php +// app/etc/env.php +return [ + // ... + 'backend' => [ + 'frontName' => 'admin' // To lower the risk of brute-force attacks, change this to something unique. + ], + // ... +]; +``` + +### Cryptographic Key + +The `crypt` section in `app/etc/env.php` contains the cryptographic key. It is used by Magento to encrypt sensitive data +such as passwords and credit card numbers. The following snippet shows the default cryptographic key: + +```php +// app/etc/env.php +return => [ + 'crypt' => [ + 'key' => 'YOUR_CRYPT_KEY' + ] +]; +``` + +> **Note** +> You can use multiple versions of the cryptographic key. This is useful when you need to change the cryptographic key +> without invalidating existing encrypted data. For more information, +> see [Encryption key management](https://devdocs.mage-os.org/docs/main/best-practices-for-secure-development). -## System Configuration -The system configuration in Magento 2 allows you to set up and manage various aspects of your e-commerce store. -To access the system configuration, follow these steps: - -1. Log in to the Magento 2 admin panel. -2. Navigate to **Stores** > **Configuration**. - -### Example: Changing the Base URL - -One of the most crucial system configuration settings is the Base URL. This setting determines the URL that customers -will use to access your store. - -To change the Base URL: - -1. Go to **Stores** > **Configuration**. -2. In the left-hand menu, click on **General** > **Web**. -3. Expand the **Base URLs (Secure)** or **Base URLs (Unsecure)** section, depending on your requirements. -4. Enter the desired URL in the **Base URL** field. -5. Click on **Save Config**. - -## Store Configuration - -Store configuration settings in Magento 2 allow you to customize various aspects related to your store's appearance and -functionality. - -To access the store configuration, follow these steps: - -1. Log in to the Magento 2 admin panel. -2. Navigate to **Stores** > **Configuration**. - -### Example: Changing the Store Name - -The store name is displayed prominently on your website and should reflect your brand and business. - -To change the store name: - -1. Go to **Stores** > **Configuration**. -2. In the left-hand menu, click on **General** > **Store Information**. -3. Enter the desired store name in the **Store Name** field. -4. Click on **Save Config**. - -## Catalog Configuration - -Catalog configuration settings in Magento 2 allow you to manage how your products are displayed, categorized, and -priced. - -To access the catalog configuration, follow these steps: - -1. Log in to the Magento 2 admin panel. -2. Navigate to **Stores** > **Configuration**. - -### Example: Setting Up Product Categories - -Product categories help customers navigate your store and find the products they are looking for. To set up product -categories: - -1. Go to **Stores** > **Configuration**. -2. In the left-hand menu, click on **Catalog** > **Catalog**. -3. Expand the **Category Top Navigation** section. -4. Enable the **Enable Category Top Navigation Menu** option. -5. Click on **Save Config**. - -## Payment Configuration - -Payment configuration settings in Magento 2 allow you to set up and manage the payment methods available to your -customers. - -To access the payment configuration, follow these steps: - -1. Log in to the Magento 2 admin panel. -2. Navigate to **Stores** > **Configuration**. - -### Example: Enabling PayPal Express Checkout - -PayPal Express Checkout is a popular payment method. To enable PayPal Express Checkout: - -1. Go to **Stores** > **Configuration**. -2. In the left-hand menu, click on **Sales** > **Payment Methods**. -3. Expand the **PayPal Express Checkout** section. -4. Set the **Enabled** option to **Yes**. -5. Enter your PayPal API credentials in the appropriate fields. -6. Click on **Save Config**. - -## Shipping Configuration - -Shipping configuration settings in Magento 2 allow you to manage how shipping is calculated and handled in your store. - -To access the shipping configuration, follow these steps: - -1. Log in to the Magento 2 admin panel. -2. Navigate to **Stores** > **Configuration**. - -### Example: Configuring Flat Rate Shipping - -Flat rate shipping charges a fixed rate for shipping regardless of the order's weight or location. To configure flat -rate shipping: - -1. Go to **Stores** > **Configuration**. -2. In the left-hand menu, click on **Sales** > **Shipping Methods**. -3. Expand the **Flat Rate** section. -4. Set the **Enabled** option to **Yes**. -5. Configure the **Title**, **Method Name**, **Price**, and other relevant fields. -6. Click on **Save Config**. - -## Conclusion - -In this documentation, we have covered the basic configuration settings in Magento 2, including system, store, catalog, -payment, and shipping configurations. By following the provided instructions and using the code snippets and examples, -you can easily configure your Magento 2 store to meet your specific requirements. For more advanced configuration -options, refer to the official Magento 2 documentation or consult with a Magento developer. From 126b4e8a111cda11ebe7a3a1e3f08d64c1266432 Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Wed, 27 Sep 2023 21:35:34 +0200 Subject: [PATCH 2/2] :pencil: Added a few low hanging fruits --- basic-configuration.md | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/basic-configuration.md b/basic-configuration.md index 25cf1e9..502f506 100644 --- a/basic-configuration.md +++ b/basic-configuration.md @@ -79,5 +79,50 @@ return => [ > without invalidating existing encrypted data. For more information, > see [Encryption key management](https://devdocs.mage-os.org/docs/main/best-practices-for-secure-development). +### Directories +The `directories` section in `app/etc/env.php` only has one child element, `document_root_is_pub`. It is used by Magento +to determine whether the document root is the `pub` directory. The following snippet shows the default value: +```php +// app/etc/env.php +return [ + // ... + 'directories' => [ + 'document_root_is_pub' => true + ], + // ... +]; +``` + +### Downloadable Domains + +The `downloadable_domains` section in `app/etc/env.php` serves as a whitelist of domains from where users can download +downloadable products after they purchese them. The following snippet shows the default value: + +```php +// app/etc/env.php +return [ + // ... + 'downloadable_domains' => [ + 'localhost' + ], + // ... +]; +``` + +### Install Date + +The `install` section in `app/etc/env.php` contains the installation date. It is used by Magento to determine the +installation date. The following snippet shows the default value: + +```php +// app/etc/env.php +return [ + // ... + 'install' => [ + 'date' => 'Thu, 01 Jan 1970 00:00:00 +0000' + ], + // ... +]; +```