To improve code readability and ensure compatibility between modules from different developers, we strongly recommend following these naming conventions.
Root scripts and HTML templates — lowercase, words separated by underscores:
index.php
page_catalog.php
main.htm
page_404.htm
item_product.htm
Module scripts follow a three-part naming scheme, separated by underscores:
{company}_{group}_{purpose}.php
melbis. For your own
projects, choose a unique identifier: it will distinguish your modules
from the built-in ones and from third-party modules if you integrate
external code.Examples:
melbis_base_page.php — base page router
melbis_store_card.php — product card
melbis_cataloge.php — catalog
melbis_inc_logic.php — business logic library
melbis_block_slider.php — slider
melbis_client_auth.php — client authentication
Library names have four parts: the word inc takes the
place of the group, and the library’s own group moves to the next part
of the name — more on this below, in the “Module Groups” section.
In addition to the code itself, each module has parameters — cache, input data, table list, connected libraries. These are configured in the “Development Environment” window, in the right panel next to the code editor, and are stored together with the module. This is described in more detail in the “Module Scripts” section.
The group in a module’s name carries semantic meaning and determines
how the module is displayed in the “Development Environment” tree. Only
one group name is reserved — inc (also
allowed: include or an empty value). Modules with this
group are libraries: they cannot have HTML templates, and the parser
does not call them directly — their functions are used by other
modules.
All other group names (base, store,
cataloge, basket, client,
block, cron, and any others) are defined by
you based on your project’s architecture. A group is simply a way to
organize modules in the file tree.
melbis_base_page.php — regular module (group base)
melbis_store_card.php — regular module (group store)
melbis_block_slider.php — regular module (group block)
For libraries, the word inc takes the place of the
group, so the library’s own group moves to the next part of the
name:
{company}_inc_{group}_{purpose}.php
In the “Development Environment” tree, libraries are organized by
this group — alongside regular modules at the same level, but with their
own icon. There is no longer a shared inc folder where all
project libraries would be dumped:
melbis
auth melbis_inc_auth.php
logic melbis_inc_logic.php
web melbis_inc_web_callback.php
melbis_inc_web_topic.php
base melbis_base_footer.php
melbis_base_head.php
melbis_base_header.php
melbis_base_page.php
basket melbis_basket.php
cataloge melbis_cataloge.php
melbis_cataloge_sub.php
The purpose can be omitted if there is only one library in the group:
melbis_inc_logic.php represents group logic
with no purpose, while melbis_inc_web_callback.php
represents group web with purpose
callback.
The idea is to keep a library close to the modules that use it:
melbis_inc_web_callback and
melbis_inc_web_topic belong to the web part of the project
and are grouped under web, rather than being scattered
among all other libraries.
Each regular module contains a main function — its name exactly matches the module’s filename written in uppercase. This is the function the parser calls:
// File: melbis_store_card.php
function MELBIS_STORE_CARD($mVars)
{
...
}The exception is library modules in the inc group. The
parser does not call them, so they have no main function. Instead, they
contain a set of helper functions that are explicitly called from other
modules.
Helper functions within the same module are named with the main function’s name as a prefix:
function MELBIS_STORE_CARD_price($mTpl, $mId)
{
...
}
function MELBIS_STORE_CARD_features($mTpl, $mId)
{
...
}This approach guarantees unique function names in PHP’s global namespace and makes it immediately clear which module a given function belongs to.
Functions in library modules (inc)
follow the same naming scheme — prefixed with the library name:
// File: melbis_inc_logic.php
function MELBIS_INC_LOGIC_order_create(...) { ... }
function MELBIS_INC_LOGIC_order_calc(...) { ... }
function MELBIS_INC_LOGIC_order_edit(...) { ... }| Variable type | Rule | Example |
|---|---|---|
| Function input parameters | Start with $m, followed by camelCase |
$mVars, $mTopicId, $mTpl |
| Local variables | Lowercase, words separated by _ |
$id, $item_count,
$command |
| PHP constants | Uppercase, words separated by _ |
MELBIS_CACHE, MELBIS_LANG |
In a module’s main function, the input parameter array is conventionally named
$mVars.
All template engine keys are written in uppercase, with words separated by underscores:
{TITLE}
{PAGE_NAME}
{PRODUCT:PRICE_OLD}
{#ITEMS}
<a href="?id={ID}">{NAME|html}</a>
{ITEMS#}