You are previewing Magento Extensions Development.
O'Reilly logo
Magento Extensions Development

Book Description

Design, build, and maintain a powerful, secure, and complete extension for Magento 2, the world’s favorite e-commerce platform

About This Book

  • Deploy a complete real-world extension step by step

  • Construct your extension with the best and most up-to-date development methods

  • Learn about team working and code sharing

  • Who This Book Is For

    If you want to write a specific customization or a large new and full-featured extension on Magento 2, this book is intended for you. You must be an intermediate to professional-level developer in PHP to appreciate this book.

    What You Will Learn

  • Build a fully-functional complex extension to add new functionality to Magento

  • Register your code with GIT and work with your team

  • Write new layouts and templates

  • Set up a fully configurable grid and forms in the backend

  • Create code unit tests and run them through TDD

  • Propose localized contents

  • Develop optimized extensions for a high-load environment

  • Publish extensions on the Magento Connect Marketplace

  • In Detail

    Magento has been revealed as the best and the most popular open source e-commerce platform in the world, with about 250k+ online stores. Magento 2 is the most recent version of this awesome toolset: every new and modern development techniques are used to offer a real modular approach and powerful architecture.

    The book will support you in the writing of innovative and complex extensions. Starting from the beginning, we will cover how to set up a development environment that allows you to be really efficient in your functionality writing, including GIT registering and many other development tools. We then move on to provide a large overview of the best practices to scale your module in a high-load environment.

    After these foundations, you will see how to use test driven-development (TDD) and unit tests to handle your code. We then build a complex extension together, step by step, and internationally-ready. Next, you will find out how to protect the users’ data. Finally, we will take a look a publishing the extension on the new Magento Connect marketplace and how to protect your intellectual property.

    After you read this book, you will know everything you need to know to become an invaluable extension editor, whether it is for your customers’ needs or for your own requirements.

    Style and approach

    This book takes a step-by-step approach to developing the extension and learning the new concepts of developments. Each topic is explained sequentially in the process of creating the extension, and punctuated by detailed explanations of the features of the code.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Magento Extensions Development
      1. Table of Contents
      2. Magento Extensions Development
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Introduction to Extension Development
        1. Getting started
        2. Creating an extension
          1. The files that handle our extension
          2. Creating a helper
          3. Creating a controller
          4. Digging into these simple files
          5. You can now test by yourself!
        3. Managing our work with Git source control
          1. Bitbucket registration
          2. Committing our work
          3. Discovering other Git servers!
        4. Registering dependencies
          1. Discovering Composer
          2. Discovering packagist
        5. Designing TicketBlaster – the backend
          1. Creating the table for the events
          2. Creating the backend view to list the events
        6. Summary
      9. 2. Deeper Extension Development
        1. Creating the backend forms to manage events
        2. Designing the TicketBlaster module's frontend
          1. Declaring the layouts
          2. Creating a template file
          3. Creating the block files
          4. How layouts and templates work
        3. Summary
      10. 3. Best Practices and Scaling for the Web
        1. Creating a new product type
        2. Designing our extension for speed
          1. Enabling developer mode
            1. Enabling the profiler
            2. Enabling the debug logs
              1. What are logs?
              2. The PSR-3 standard
              3. The Monolog library and Magento 2
              4. How Monolog complies with PSR-3
              5. Channels and handlers
              6. How to use the Magento 2 logging system
                1. In a model
                2. In a controller
                3. In a block
              7. How to make your own custom handler and channel
            3. Enabling your browser's debug panel
            4. Get the ultimate profiler tool
            5. Write clean and efficient code
              1. Don't load any model
              2. Getting only really necessary data
              3. Don't write code twice
              4. Use helpers
              5. Use layouts
          2. Security first
            1. Five secure coding practices
              1. Validate input as strictly as possible
              2. Use parameterized queries in your database requests
              3. Escape user input
              4. Use synchronized token pattern
              5. Security headers
        3. Summary
      11. 4. Magento and Test-driven Development
        1. Why perform testing in Magento?
          1. Types of test
        2. Testing in Magento
          1. How Magento integrates PHPUnit
          2. Write unit tests with PHPUnit
            1. Assertions
            2. DataProvider
            3. Test Double
              1. How do we create and use stubs and mocks?
            4. Expectations and matchers
              1. Matchers
              2. The will method
              3. The with method
              4. Magento Test Framework
          3. Writing unit tests for TicketBlaster
          4. How to run unit tests
        3. Writing a timed checkout
          1. Writing a unit test
          2. Writing a timed checkout
          3. Executing the unit test
        4. Summary
      12. 5. Internationalization
        1. The EAV approach
        2. Store relation table
          1. Creating the new table
          2. Adding the new input to the edit form
          3. Saving the new data in the new table
          4. Showing the store views in the admin grid
          5. Modifying the frontend event list
          6. Restricting the frontend access by store view
        3. Differentiating the guests and registered users' interface
          1. Adding the isLoggedIn() method
          2. Restricting access in the template file
          3. Restricting direct access to the Details page
        4. Translation of template interface texts
          1. Translation of e-mail templates: creating and translating the e-mails
          2. Testing our code by sending the e-mail
        5. Summary
      13. 6. Optimizing for Speed and Measuring Conversion Rates
        1. Performance indicators
        2. Slow websites are not SEO-friendly
        3. Best practices
          1. Editing the .htaccess file for compression
          2. Full page cache
          3. Minify and merge CSS/JavaScript files
          4. Configuring a CDN server
          5. Redis and Memcached
        4. How to measure your speed optimization
          1. New Relic
            1. Overviewing the dashboard
            2. Tracking transactions
            3. External services monitoring
            4. Configuring customized alerts
            5. Service Level Agreement reports
            6. Browser
          2. Quanta monitoring
            1. Web scenarios
            2. Application profiling
          3. Google Analytics
          4. YSlow
          5. GTMetrix
        5. Summary
      14. 7. Module Creation Etiquette
        1. The possible attacks
          1. SQL injection
          2. Cross-site scripting
            1. Non-persistent
            2. Persistent
          3. Cross-site request forgeries
        2. The Payment Card Industry Data Security Standard
          1. Protecting stored cardholder data
          2. Encrypt transmissions
        3. Developing your own payment method
          1. Implementing the method
        4. Software considerations
          1. PHP
            1. Installing PHP
            2. Configuring PHP
            3. Configuring nginx
          2. PSR-1 to PSR-7
          3. OWASP
        5. Stay tuned
        6. Summary
      15. 8. Optimization for Teamwork Development
        1. Version control and code management
          1. Feature branch workflow
            1. Master branch
            2. Develop branch
            3. Feature branches
            4. Release branches
            5. Hotfix branch
          2. Deployment and backups
            1. Backup strategy
            2. Compressing your backup
            3. Peer programming
            4. Developing standards and code review
        2. Project management methodology
        3. Communicating in a developer team
          1. Team awareness of workflow
          2. Slack
        4. Summary
      16. 9. Magento Marketplace
        1. The new Connect is called Marketplace
          1. The end of the existing Connect website
          2. A new business model
          3. A specific submission workflow
            1. The Magento Extension Distribution and Service Agreement
              1. Coding standards
              2. Branding
              3. Pricing and licensing
            2. Packaging and submitting the extension
            3. The product profile
            4. Your personal and company profiles
            5. Technical review
            6. Marketing review
        2. Selling extensions by ourselves
          1. The downloadable product
            1. Managing versions with downloadable information
            2. Selling additional services
          2. Having a store is not enough
        3. Summary
      17. Index