Categories


Archives


Recent Posts


Categories


Magento 2 UI Component Code Generation

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

The quick version: I’ve just released a new version of pestle, my command line framework and Magento 2 code generation tool. The latest version contains a set of commands that can create a “full” Magento module, including a UI Component Grid and UI Component Form. If you’re a pestle user, just run

$ pestle.phar selfupdate

and you’ll have the latest version. If you’re not a pestle user, there’s simple installation instructions in the GitHub README. If you’re looking for examples of how to use pestle to create a module, this bash script will create a simple module that creates, reads, updates, and deletes “thing” objects.

It’s also time, once again, for me to ask for your help.

No, I’m not going to ask you to buy a copy of Commerce Bug 3 (although it is the world’s best Magento debugging extension, and programers who buy it instantly see “easy things are now easy, hard things are now possible” style productivity boosts.

I’m also not going to ask you to sign up for my Patreon (although developers who do gain access to me for one-on-one socratic Magento tutoring sessions and it helps keep the lights on here).

Today is all about asking for help on a 100% open source (in license and in spirit) project — namely pestle’s module and UI Component generating code.

While we now have all the basic commands for a user to create a fully functional, one-model/one-table CRUD module with a configured UI Grid and UI Form, our work’s far from done. The generated module’s still in a “rough draft” state. What we need help with now is

  1. Testing the commands
  2. Improving the code quality of the created module

How to Help

The easiest way to help? Grab a copy of pestle, use it the next time you want to create a Magento 2 module, and let us know what doesn’t work and/or needs improvement.

If you want to do a little more, the previously linked GitHub project contains two things.

  1. Code for an example module created by pestle
  2. A module.bash shell script that uses pestle to create a full module

If you download pestle, grab the shell script, and run the shell script from the root of your Magento system, you should have a “Pestle Things” link in your admin that links to a fully working UI Grid (configured to show the model ID an edit link), and a form to edit the model’s information (configured with a single, collapsed “title” editing field).

The current generated code was cobbled together by “cargo cult-ing” (i.e. copying without always understanding) the syntax/patterns in Magento 2’s code module. The CRUD module code that makes up the core of Magento’s functionality are, ironically, the modules most in need of some refactoring effort. Unlike Magento 1, there’s no clear pattern on what makes a “good” CRUD module, and the core team’s attention seems focused elsewhere.

The code pestle creates works, but I’d like it to work and be good code. The purpose of the magento2-pestle-platonic-module-output project is to take this “working-but-sort-of-janky” code and move it towards a community driven idea of what a good CRUD module looks like.

That’s something I can’t do alone. That’s where I need your help.

Specific Things you Can Do

The first thing you can do? Take a look at the open issues and let me know what you think about the questions and problems mentioned inside. No thought is too trivial to share.

The second thing? The repository contains a sample module named Pulsestorm_Pestleform. If there’s something in this module’s code that you think “sucks” or “could be better”, let us know via the issues or, better yet, submit a pull request to fix it. As the code quality of Pulsestorm_Pestleform improves, we’ll incorporate these changes into pestle itself.

This brings us to the third thing you can do. If you want to get involved in pestle development, there’s a huge issue backlog. It turns out creating a new PHP command line system from scratch while also creating a Magento 2 code generation system is more work that you’d think. Pestle’s philosophy is a little off the beaten path, but it’s a project I have a lot of fun with and no contribution is too small.

That’s all for today — thanks again to both my Patrons (for making this free and open source code possible), and to all of you for reading.

Series Navigation<< Magento 2: Knockout.js Template Primer

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 15th February 2017

email hidden; JavaScript is required