Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Added a few sections for the env.php #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 125 additions & 118 deletions basic-configuration.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,128 @@
# 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.

## 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.
## 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ENV variable config option is missing in the list here.


## 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could description the replication setup here as well. Maybe as separate chapter?

This is an example config:

return array (
      //...
      'db' =>
         array (
            'connection' =>
               array (
                  'indexer' =>
                     array (
                        'host' => 'default-master-host',
                        'dbname' => 'magento',
                        'username' => 'magento',
                        'password' => 'magento',
                        'active' => '1',
                        'persistent' => NULL,
                     ),
                  'default' =>
                     array (
                        'host' => 'default-master-host',
                        'dbname' => 'magento',
                        'username' => 'magento',
                        'password' => 'magento',
                        'active' => '1',
                     ),
                  'checkout' =>
                     array (
                        'host' => 'checkout-master-host',
                        'dbname' => 'checkout',
                        'username' => 'magento',
                        'password' => 'magento',
                        'model' => 'mysql4',
                        'engine' => 'innodb',
                        'initStatements' => 'SET NAMES utf8;',
                        'active' => '1',
                     ),
                  'sales' =>
                     array (
                        'host' => 'sales-master-host',
                        'dbname' => 'sales',
                        'username' => 'magento',
                        'password' => 'magento',
                        'model' => 'mysql4',
                        'engine' => 'innodb',
                        'initStatements' => 'SET NAMES utf8;',
                        'active' => '1',
                     ),
               ),
            'slave_connection' =>
               array (
                  'default' =>
                     array (
                        'host' => 'default-slave-host',
                        'dbname' => 'magento',
                        'username' => 'read_only',
                        'password' => 'password',
                        'active' => '1',
                     ),
                  'checkout' =>
                     array (
                        'host' => 'checkout-slave-host',
                        'dbname' => 'checkout',
                        'username' => 'read_only',
                        'password' => 'password',
                        'model' => 'mysql4',
                        'engine' => 'innodb',
                        'initStatements' => 'SET NAMES utf8;',
                        'active' => '1',
                     ),
                  'sales' =>
                     array (
                        'host' => 'sales-slave-host',
                        'dbname' => 'sales',
                        'username' => 'read_only',
                        'password' => 'password',
                        'model' => 'mysql4',
                        'engine' => 'innodb',
                        'initStatements' => 'SET NAMES utf8;',
                        'active' => '1',
                     ),
                  ),
               'table_prefix' => '',
   ),
   //.......

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely worth its own chapter, yes


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).

### 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'
],
// ...
];
```