-
Notifications
You must be signed in to change notification settings - Fork 224
Development Setup
We provide a ddev setup for developers which helps you to:
- Setup the developnment environment in Docker
- Install Magento test environments for Magento 2.3 and Magento 2.4
- Commmands to run qa checka and PHPUnit tests
To start the environment, follow this steps:
- Register two environment variables in ddev holding the Magento repository credentials. The variables are used to download Magento 2 source code.
ddev config global --web-environment="MAGENTO_REPO_USERNAME=<add-your-key-here>,MAGENTO_REPO_PASSWORD=<add-your-secret-here>"
More details: https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container
Please note that the command will override all already existing global ddev variables. If you already have variables then open the global ddev config file manually. It is here:~/.ddev/global_config.yaml
. -
ddev start
The ddev setup should install all Composer dependencies and setup test Magento instances.
Check code against coding standard rules.
ddev qa
ddev unit-test-24
ddev unit-test-23
If you start with ddev start
then we try to install a test environment inside the container.
The version if this default installation is defined as variable MAGERUN_SETUP_TEST_DEFAULT_MAGENTO_VERSION
in the .ddev/config.yaml
file.
The test installations are installed in the directory /opt/magento-test-environments/magento_<version>
.
Please note that the Magento installation need to be compatible with your ddev PHP settings.
We offer the command install-magento-ce
(and install-magento-ce-git
which allows to install from Github Repo) which allows you to manually install any Magento version you like to test.
If you try to install very old Magento version, please change the PHP version with ddev config --php-version=<version>
before you install.
The command has two parameters:
ddev install-magento-ce <version> <use_elasticsearch yes|no>
Examples:
ddev install-magento-ce 2.4.6 yes
ddev install-magento-ce 2.4.5-p2 yes
Example with custom PHP version only for installation:
ddev ssh
composer self-update --1
PHP_BIN=php7.4 install-magento-ce 2.3.7 no
composer self-update 2.2.17
php7.4 bin/n98-magerun2 --root-dir=/opt/magento-test-environments/magento_2_3_7 sys:info
You can easily run any Magerun command you are developing.
Login to your container with ddev ssh
.
The run bin/n98-magerun2
with --root-dir
option and define the command.
Example:
bin/n98-magerun2 --root-dir=/opt/magento-test-environments/magento_2_4_6 sys:info
We offer a ddev command to copy the required Magento source code of the Test-Installation to your project root.
Run ddev get-magento-source
command to start the copy process.
The command will then start a setup:di:compile
to generate all required files.
After the compilation all required files are compiled to a phar file which then gets extracted to your project root directory.
In your project should then be the directory magento-src
which is ignore in the .gitignore file.
IDEs like PhpStorm should then rebuild the index and provide the right code completion.