Much of the configuration in Magento 2 is done by xml files, and placed in the [Module_Root]/etc/ directory. Depending on the scope of your configuration, place them in etc/adminhtml, etc/frontend or under global scope under etc/. When you put them in adminhtml or frontend, this overwrites the global scope.
One of the first things you can do to get started with component development is to understand and set up the file system. Each type of component has a different file structure, although all components require certain files. In addition, you can choose the component root directory to start development. The following sections have more information. — Magento DevDocs — About component file structure
A component root directory can take place in 2 places, /app and /vendor, and it’s the top-level directory for that component.
Let’s start with what a module is, how a module works and how we can register it.
The Magento 2 documentation explains the following about modules:
A module is a logical group — that is, a directory containing blocks, controllers, helpers, models — that are related to a specific business feature. In keeping with Magento’s commitment to optimal modularity, a module encapsulates one feature and has minimal dependencies on other modules. — Magento DevDocs — Module overview
Sequel Pro is an open-source SQL Client for macOS, and for many Developers (myself included) the must-have tool when dealing with a SQL server. It’s fast, has an easy interface, and is very intuitive to use.
You may have noticed that in recent years little has changed in terms of features and how it looks. After some recent updates in macOS, I keep running into new bugs in Sequel Pro:
It is possible to configure multiple instances in Magento.
Each instance can contain different attributes, including Languages, Domain names, Categories, Products, Currencies and more.
A Magento installation can have multiple websites that have multiple stores or store views.
Global: At the top of the hierarchy. This is what you get when you install Magento. This includes all default configuration.
Website: Magento installations begin with a single website which by default, is called Main Website. You can also set up multiple websites for a single installation, each with its own IP address and domain.
Store: A single website can have multiple…
In warden it is possible to set up multiple domains for your project. Warden uses Traefik and is installed as a Global Service.
Traefik ensures that requests are intercepted and sent to the correct back-end service e.g. https: //app.example1.test https: //app.example2.test. For this it uses an HTTP reverse proxy and a load balancer.
It also has a dashboard to monitor different metrics. This can be found if you go to https: https://traefik.warden.test/.
A reverse proxy is a server that sits in front of web servers and forwards client (e.g. web browser) requests to those web servers.
When I just started developing PHP applications I used Mamp or Xamp to set up a local Lamp stack.
Later this became Vagrant in combination with VirtualBox and eventually Docker.
The main advantage of Docker is portability, performance and it is scalable. This pays off, especially when you work in a team.
When using commerce with Magento 2 it is possible to use the Magento Cloud Docker environment.
Brief introduction to docker
The main difference between Docker and a VM is mainly the architecture between the 2. A VM is a computer software that mimics a real computer. …
Magento 2 has a wide range of tools that help you with developing modules. One of the well-known CLI tools in Magento is Magerun. This is an extension of Magento’s own CLI tool that already comes out of the box when you install Magento 2. One of my favorite tools that I use a lot is Pestle by Alan Storm.
Since much of our code we write mainly consists of template (reusable) code, Pestle helps to generate a lot of this code. Ultimately, this saves a lot of time when it comes to developing Magento 2 modules.
What is Pestle
In the first part we discussed what declarative schemes are, why you should use declarative schemes instead of install / upgrade scripts, how to create, edit and eventually delete a declarative. If you haven’t already read the first part, I suggest you take a moment to read this first.
As an example, I created a simple module containing a InstallSchema.php that looks like this.
Migrate install/upgrade scripts to a declarative scheme
Now it is also possible to convert existing installation / upgrade scripts to a declarative scheme with the “Schema Listener Tool”. It is useful to know that using…
When we make changes to our database it’s usually done through an installation or upgrade script. We start by creating an install script that has a php class “InstallSchema” and in it we write our PHP code to make adjustments to the database. Then when we need to change a table, we create an “UpgradeSchema”, look at the version where it needs to upgrade and add our changes.
The disadvantages of using installation scripts
During installation, Magento goes through all versions of the module until the latest version is reached. That looks like this:
1.0.0 create database schema (install table…