Use Beeline to generate Magento code in PhpStorm

Now that you have PhpStorm set up, let's explore how to use it with Beeline. Beeline is a collection of code generation templates for Magento development.

Beeline Keywords

On the main sales page of Beeline, you can find a list of available keywords. These keywords are generally prefixed with m2. However, Knockout HTML keywords start with a bracket. Each keyword has a description of the code it generates. For instance, the m2koForeachRegion tag generates a foreach region code. If the keyword generates a nested code block, you will notice an arrow syntax indicating the subsequent part is a child of the parent.

Beeline is heavily focused on XML files since most of the typing in Magento is done in XML. Some keywords are specific to certain files, and the Beeline documentation will indicate which files they can be used in.

Keep in mind that some files are dependent on their location, so you can't use these keywords wherever you want. For example, m2controller expects the file to be located at Controller/Index/Index.php or any name following that format.

Using Beeline in PhpStorm

Let's see how to use Beeline in practice within PhpStorm. First, create a new module and name it MarkShust/MyFoo. Then create a registration.php file within this module. To generate the content using Beeline, open a PHP tag and start typing m2registration. PhpStorm will auto-complete the keyword for you, and upon pressing enter or tab, the file content is generated.

Similarly, you can generate the content for other files like etc/module.xml, db_schema.xml, and controller classes, by using the appropriate Beeline keywords.

To view or modify Beeline keywords and templates in PhpStorm, navigate to Settings > Editor > Live Templates. If you want to customize any of the templates, it's recommended to duplicate them and create your own keywords to avoid conflicts with future updates.

If you have any new ideas or keywords to contribute, feel free to create a pull request on the GitHub repository. Good luck using Beeline in your Magento development projects!

Complete and Continue  
Extra lesson content locked
Enroll to access all lessons, source code & comments.
Enroll now to Unlock