Magento 2 Development Quick Start Guide
eBook - ePub

Magento 2 Development Quick Start Guide

Build better stores by extending Magento

Branko Ajzele

  1. 218 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Magento 2 Development Quick Start Guide

Build better stores by extending Magento

Branko Ajzele

Book details
Book preview
Table of contents
Citations

About This Book

Create an interactive online store and customize it further using Magento

Key Features

  • A straightforward guide to developing with Magento
  • Examples of different types of extension
  • Customize the Magento storefront and admin areas

Book Description

Magento is an open-source, enterprise-level e-commerce platform with unlimited scope for customization. This makes it a great choice not only for vendors but for developers as well.

This book guides you through Magento development, teaching you how to develop modules that extend or change its functionality, leading to more flexible and profitable Magento stores. You start with a structural overview of the key Magento development components.

You will learn where things such as plugins, events, models, controllers, layouts, and UI components ft into the development landscape. You will go through examples of using these components to extend Magento. As you progress, you will be building a diverse series of small but practical Magento modules.

By the end of this book, you will not only have a solid foundation in the Magento development architecture; but you will also have practical experience in developing modules to customize and extend Magento stores.

What you will learn

  • Develop a simple shipping module
  • Build admin interfaces with the built-in form and listing UI components
  • Implement JavaScript components for improved customer experience
  • Accommodate vendor needs by adding new catalog-related features
  • Develop your way to a better checkout
  • Improve customer interaction with new customer-related extensions
  • Create new web APIs to make your modules more extensible

Who this book is for

This book is for competent PHP developers, with only basic knowledge of the Magento platform required.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Magento 2 Development Quick Start Guide an online PDF/ePUB?
Yes, you can access Magento 2 Development Quick Start Guide by Branko Ajzele in PDF and/or ePUB format, as well as other popular books in Informatik & Content-Management-Systeme. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781789345469

Understanding the Magento Architecture

Building web shops is a challenging and tedious job, and even more so if a platform you are working on is limited via features, extensibility, and the overall ecosystem it provides. Choosing the right platform can often make the difference between a project's success or failure. The abundance of available e-commerce software, from SaaS to self-hosted solutions, does not really make it an easy choice.
The Magento e-commerce platform has been around for over 10 years now. With its first stable release dating back to March 2008, it immediately caught the attention of developers as an extensible and feature-rich open source platform. Over time, Magento established itself as not just a stunning technical and feature-rich platform, but as a robust ecosystem as well. By allowing developers to validate their real-world skills through the Magento certification program, certain standards have been put into effect, making it easier for merchants to better recognize their solution partners. Training courses have been further provided for other roles in e-commerce business as well, such as merchants, marketers, system administrators, and business analysts.
In this chapter, we will take a look at some of the key must-knows about Magento:
  • Installing Magento
  • Modes
  • Areas
  • Request flow processing
  • Modules
  • Cache
  • Dependency injection
  • Plugins
  • Events and observers
  • Console commands
  • Cron jobs
To keep things compact as we move forward, let's assume the following throughout this book:
  • We are working on the magelicious.loc project
  • We are referring to our project root directory as <PROJECT_DIR>
  • We are referring to the <PROJECT_DIR>/app/code/Magelicious directory as <MAGELICIOUS_DIR>
  • We are referring to Magento's vendor/magento directory as <MAGENTO_DIR>
  • We have a running LAMP/MAMP/WAMP stack (Apache, MySQL, PHP) that is compliant with Magento's requirements
  • We have a Composer package manager installed
  • We have access to crontab (Linux, MacOS) or Task Scheduler (Windows)
AMPPS is an easy to use, all in one LAMP/MAMP/WAMP software stack from Softaculous, which enables Apache, MySQL, and PHP. With AMPPS, you can even install Magento 2.x by the click of a button, which means it comes loaded with all the right PHP extensions. While it isn't suited for production purposes, it comes in handy for quickly kicking the development environment. See http://www.ampps.com/ for more information. Consult the devdocs (https://devdocs.magento.com) for Magento technology stack requirements.

Technical requirements

You will need to have basic knowledge of PHP, OOP, JavaScript, and XML. You will also need Apache, MySQL, and AMPPS installed on your system to execute the codes.
The code files of this chapter can be found on GitHub:
https://github.com/PacktPublishing/Magento-2-Quick-Start-Guide.
Check out the following video to see the Code in Action:
http://bit.ly/2D8kOlF.

Installing Magento

The Magento platform comes in two flavors:
  • Magento Open Source: The free version, targeting small businesses
  • Magento Commerce: The commercial version, targeting small, medium, or enterprise businesses
The difference between the two comes mainly in the form of extra modules that were added to the Commerce version, whereas all the coding concepts and core features remain the same. It goes to say that any knowledge we obtain through following Magento Open Source examples is fully applicable to anyone working on Magento Commerce.
There are several ways that we can obtain source files for Magento Open Source:
  • Source file archive (.zip, .tar.gz, .tar.bz2), available at https://magento.com
  • Git repository, available at https://github.com/magento/magento2
  • Composer repository, available at https://repo.magento.com
Obtaining source files via a CLI from the composer repository is our preferred method. Assuming we are within the empty <PROJECT_DIR> directory, we can kick off this process via the following command:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
The dot (.) at the end of this command this tells the composer to pull the files into a current directory.
Once the Composer process is finished, we can start installing Magento. There are two ways we can install Magento:
  • Via the Web Setup Wizard: The graphical, browser-based process
  • Via the command line: The command-line-based process
Knowing how to install Magento via the command line is an essential skill in day-to-day development, as the majority of development requires the developer to tackle various bin/magento commands—not to mention the command line approach is somewhat faster and easily scripted.
Let's install Magento with the built-in php bin/magento setup:install command and a few of the required installation options as follows:
php bin/magento setup:install \
--db-host="/Applications/MAMP/tmp/mysql/mysql.sock" \
--db-name=magelicious \
--db-user=root
--db-password=root \
--admin-firstname=John \
--admin-lastname=Doe \
[email protected] \
--admin-user=john \
--admin-password=jrdJ%0i9a69n
After the preceding command has been executed, we should begin to see console progress, starting with something like the following:
Starting Magento installation:
File permissions check...
[Progress: 1 / 513]
Required extensions check...
[Progress: 2 / 513]
Enabling Maintenance Mode...
[Progress: 3 / 513]
Installing deployment configuration...
[Progress: 4 / 513]
Installing database schema:
Schema creation/updates:
Module 'Magento_Store':
[Progress: 5 / 513]
While it might take up to a few minutes, a successful installation should end with a message that's similar to the following:
[Progress: 508 / 513]
Installing admin user...
[Progress: 509 / 513]
Caches clearing:
Cache cleared successfully
[Progress: 510 / 513]
Disabling Maintenance Mode:
[Progress: 511 / 513]
Post installation file permissions check...
For security, remove write permissions from these directories: '/Users/branko/Projects/magelicious/app/etc'
[Progress: 512 / 513]
Write installation date...
[Progress: 513 / 513]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_mxq00c
Nothing to import.
Right after installation, our first step should be to set Magento to developer mode by using the following command:
php bin/magento deploy:mode:set developer
We will take a closer look at Magento modes soon; for now, this is to be taken as is.
Magento automatically assigns an admin URL during console installation, unless explicitly specified through the install command via the --backend-frontname option.
Out of all the installation options listed, only the following are actually required: --admin-firstname, --admin-lastname, --admin-email, --admin-user, and --admin-password. It is worth taking some time to read through the official Magento documentation (https://devdocs.magento.com) and looking at what the rest of the installation options have to offer.
If all went well during the Magento installation, we should be able to open the storefront and admin in our browser.

Modes

Modes play a crucial role in Magento's development and deployment processes. They are handled by the deploy module, which can be found under...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Packt Upsell
  4. Contributors
  5. Preface
  6. Understanding the Magento Architecture
  7. Working with Entities
  8. Understanding Web APIs
  9. Building and Distributing Extensions
  10. Developing for Admin
  11. Developing for Storefront
  12. Customizing Catalog Behavior
  13. Customizing Checkout Experiences
  14. Customizing Customer Interactions
  15. Other Books You May Enjoy
Citation styles for Magento 2 Development Quick Start Guide

APA 6 Citation

Ajzele, B. (2018). Magento 2 Development Quick Start Guide (1st ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/823706/magento-2-development-quick-start-guide-build-better-stores-by-extending-magento-pdf (Original work published 2018)

Chicago Citation

Ajzele, Branko. (2018) 2018. Magento 2 Development Quick Start Guide. 1st ed. Packt Publishing. https://www.perlego.com/book/823706/magento-2-development-quick-start-guide-build-better-stores-by-extending-magento-pdf.

Harvard Citation

Ajzele, B. (2018) Magento 2 Development Quick Start Guide. 1st edn. Packt Publishing. Available at: https://www.perlego.com/book/823706/magento-2-development-quick-start-guide-build-better-stores-by-extending-magento-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Ajzele, Branko. Magento 2 Development Quick Start Guide. 1st ed. Packt Publishing, 2018. Web. 14 Oct. 2022.