Use Beeline to generate Magento code in PhpStorm

Now that you have PhpStorm set up, let's go over how to use it with Beeline templates. Beeline offers numerous templates to streamline your workflow, with 96 templates currently available and more added regularly.

Beeline Keyword Structure

All Beeline keywords generally begin with m2, with the exception of Knockout HTML keywords, which start with a bracket. Remember that Knockout HTML templates start with a bracket, just like HTML does.

Next to each keyword is a description of what the keyword generates. For example, the m2koForeachRegion tag generates a foreach region code. If the keyword generates a nested code block, you will see an arrow syntax, indicating that the subsequent part is a child of the parent.

XML Keywords

Beeline is heavily biased towards XML files, as this is the majority of typing done in Magento. The template will indicate if a keyword is applicable only to a specific file, and what file it is commonly used in.

Creating Files with Beeline Keywords

When using Beeline keywords in PhpStorm, you must follow specific file structures and locations for the keywords to work properly. For example, the m2controller keyword expects the file to be located at Controller\\Index\\Index.php, or any name following that format.

PHP Files

To use a keyword in a PHP file, always start with a PHP tag and then enter a space before typing the keyword. This is because PHP files are an exception in Beeline.

Creating Tables with Beeline

When using Beeline to generate a table in Magento, the table name is prefixed with the vendor name and module name. A placeholder text is inserted, which you can replace with your desired name. Beeline tries to auto-generate comments wherever possible.

Generating Controller Classes

When generating a controller class with Beeline, you have the option to create a standard controller, an admin controller, or a JSON controller. The generated file will include the necessary properties and an example of data returned.

Customizing Beeline Keywords

If you wish to customize the Beeline keywords, you can do so in PhpStorm's settings under Editor > Live Templates. It is recommended to duplicate the template and create your own custom keyword to avoid conflicts or overwrites when Beeline updates.

Contributing to Beeline

If you have any ideas or new keywords that you wish to contribute, feel free to create a pull request on the GitHub repository. Good luck with using Beeline, and if you have any questions, be sure to leave a comment below.

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