Prep environment for admin grid development
Before starting Magento development, there are a few things you need to do to prepare your environment. This lesson will walk you through the steps to make your development process smoother and more efficient.
Disabling Two-Factor Authentication
When logging into the Magento admin, you may notice a message prompting you to set up two-factor authentication (2FA). While 2FA offers added security, constantly entering 2FA codes during development can be a hassle. To address this issue, you can use a module called
DisableTwoFactorAuth. This module allows you to control whether 2FA is enabled or disabled, depending on your environment.
To install this module, follow these steps:
- Use Composer to install the module by executing the appropriate command in your terminal.
- Enable the module in Magento by executing the required command in your terminal.
- Clear the cache by running the
Remember that 2FA is still enabled by default after installing the module. You can disable it either through the admin panel or by running the appropriate command in your terminal.
Enabling Developer Mode
Enabling developer mode is crucial for Magento development. This mode allows for easier debugging and other useful features when working on your project. To enable developer mode, follow these steps:
- Open your terminal and check if developer mode is enabled by running the
- If the current mode is “default”, change it to “developer” by running the
bin/magento deploy:mode:set developercommand.
Installing and Configuring IDE Plugins for Magento
Installing and configuring the appropriate Magento plugin for your Integrated Development Environment (IDE) can greatly improve your development workflow. For example, the Magento PhpStorm plugin offers several useful features, such as command-clicking into XML files.
To set up the PhpStorm plugin, follow these steps:
- Open PhpStorm and navigate to
Preferences > Plugins.
- Click on the
Marketplacetab and search for “Magento”.
- Install the Magento PhpStorm plugin and restart PhpStorm.
After installing the plugin, enable it for your current project by going to the
Languages & Frameworks > PHP > Framework section in PhpStorm’s preferences. Make sure to check the “Enable Magento integration” box and set the correct local installation path and Magento version.
Improving Cache Management with the Magento-Cache-Clean Module
magento-cache-clean module by Vinai Kopp can significantly improve your development experience by automatically clearing caches when changes are detected in your project. To install this module, follow these steps:
- Install the module with Composer by executing the appropriate command in your terminal.
- Start the cache watcher by running the required command in your terminal.
With this module installed, you no longer need to manually flush caches when making changes to your project.
Enabling Magento Coding Standards
It’s a good idea to enable the official Magento Coding Standards for your development. These standards are recommended by Magento and are required for submitting modules to the Magento Marketplace. To enable these standards, follow these steps:
- Install the Magento Coding Standards with Composer by executing the appropriate command in your terminal.
- Add the necessary lines to your
Finalizing Your Environment
With your environment prepared, you can now log into the Magento admin and make some final adjustments. To avoid having to constantly log in during development, increase the admin session lifetime to the maximum value (one year). This can be done by navigating to
Stores > Configuration > Advanced > Admin > Security, and adjusting the “Admin Session Lifetime” setting.
After making these changes, flush the Magento cache, and you’re all set to start your Magento development.