Book Image

Magento 2 Developer's Guide

Book Image

Magento 2 Developer's Guide

Overview of this book

Magento is one of the most exciting, flexible, and customizable e-commerce systems. It offers you an extensive suite of powerful tools for creating and managing an online store. After years of development, Magento 2 introduces itself with a strong emphasis on modularity, Web API's, automated testing and overall new technology stack platform.The long-awaited Magento 2 release introduces a whole new e-commerce platform to develop online stores. The all new Magento 2 architecture, Web APIs, and a host of other features are equally challenging to master as much as they are exciting to use. Tshis book will ease the learning curve by offering step-by-step guidance on how to extend the core functionality of your Magento 2 store. This book is your one-stop guide to build and customize a quality e-commerce website from the latest version of one of the largest, fastest growing, and most popular e-commerce platforms—Magento 2. We start off with an introduction to the fundamental concepts of Magento to give you a foundation to work from. We then move on to configure the development and basic production environment for Magento. After this, you’ll get to grips with the major concepts and conventions that are new to the Magento 2 platform. We then delve deeper to get to the core of automated deployments, persisting data, writing data fixture scripts and applying various backend and frontend modifications. As we near the end of the book, you will learn to make API calls and write automated tests. Finally, you will be guided through building a full-blown helpdesk module from scratch. By the end of this book, you will have learned a wide range of techniques to extend and customize your Magento 2 store to fit the requirements of your business.
Table of Contents (19 chapters)
Magento 2 Developer's Guide
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

The module filesystem structure


Magento identifies itself as a highly modular platform. What this means is that there is literally a directory location where modules are placed. Let's take a peak at the individual module structure now. The following structure belongs to one of the simpler core Magento modules—the Contact module that can be found in vendor/magento/module-contact:

  • Block

  • composer.json

  • Controller

  • etc

    • acl.xml

    • adminhtml

      • system.xml

    • config.xml

    • email_templates.xml

    • frontend

      • di.xml

      • page_types.xml

      • routes.xml

    • module.xml

  • Helper

  • i18n

  • LICENSE_AFL.txt

  • LICENSE.txt

  • Model

  • README.md

  • registration.php

  • Test

    • Unit

      • Block

      • Controller

      • Helper

      • Model

  • view

    • adminhtml

    • frontend

      • layout

      • contact_index_index.xml

      • default.xml

    • templates

      • form.phtml

Even though the preceding structure is for one of the simpler modules, you can see that it is still quite extensive.

The Block directory is where the view-related block PHP classes are located.

The Controller directory is where the controller-related PHP classes are stored. This is the code that responds to the storefront POST and GET HTTP actions.

The etc directory is where the module configuration files are present. Here, we can see files such as module.xml, di.xml, acl.xml, system.xml, config.xml, email_templates.xml, page_types.xml, routes.xml, and so on. The module.xml file is an actual module declaration file. We will look into the contents of some of these files in the later chapters.

The Helper directory is where various helper classes are located. These classes are usually used to abstract various store configuration values into the getter methods.

The i18n directory is where the module translation package CSV files are stored.

The Module directory is where the entities, resource entities, collections, and various other business classes can be found.

The Test directory stores the module unit tests.

The view directory contains all the module administrator and storefront template files (.phtml and .html) and static files (.js and .css).

Finally, the registration.php is a module registration file.