This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

Understanding LemonStand Modules

LemonStand is a modular application. All features, including eCommerce and CMS functions are supplied by different modules. By developing your own LemonStand modules you can solve the following tasks:

  • adding new features to your store
  • extending existing objects, like customers or orders
  • extending the Administration Area user interface by adding new tabs and forms

Anatomy of a LemonStand module

From a filesystem point of view, each module in LemonStand is a subdirectory of the modules directory. There are naming conventions, described below, which you should follow when you are choosing a name for a new module directory. A module directory can contain the following subdirectories:

  • classes
  • controllers
  • resources
  • models
  • updates

The classes directory should contain a module information PHP class. The classes and updates are the only directories required for creating a simplest LemonStand module. The classes directory can contain PHP classes required for your module specific needs. Also, the classes directory should contain a module information class declaration, which is described in the Developing a simple module article.

The controllers directory contains controller class files and view (HTML) files which are needed for building a module-specific user interface for the Administration Area. If you are not going to add new pages to the Administration Area, you do not need to create this directory. The process of extending the Administration Area is described in the Adding a back-end user interface article.

The resources directory can contain CSS, image and JavaScript files required for your module Administration Area user interface. You can create any subdirectories in this directory. You do not need to create this directory if you are not going to extend the Administration Area, or if you do not need resource files for your module.

The models directory can contain model class PHP scripts required for your module. You do not need to use model classes if your module have no tables in the database. Please read the Working with the database article for details about model PHP classes.

The updates directory should contain a module version information file (version.dat) and SQL or PHP scripts required for creating and updating database tables required for your module. This subdirectory is needed even if a module have no database tables. Please read the Developing a simple module and Creating and updating database tables articles for details.

Naming conventions

The LemonStand programming framework applies some simple naming conventions to file and PHP class names. The conventions allow LemonStand to load PHP classes automatically without using the require() or include() PHP functions. Also, there are some naming conventions for module directory names (or module identifiers), developed in order to avoid future conflicts between modules created by different developers.

Module directories

A module directory name cannot contain spaces, underscores and minus symbols. Module directory names should be compatible with the PHP variable and class naming conventions - for example names should not begin with a digit. All file and directory names should be written in lower case. To avoid naming collisions with other future modules please add some developer-specific prefix to your module directory names, for example a company name. LemonStand native modules do not have any prefixes. Examples of correct names of module directories:

  • abcblog - directory of some blog module developed by some ABC company
  • xyzcart - directory of some cart extension module developed by some XYZ company

Examples of incorrect module directory names:

  • abc_blog - contains the underscore symbol
  • xyz-cart - contains the minus symbol
  • 1xyzcart - the first character should not be a digit
  • xyzCART - contains upper-case letters

PHP class names

Each class defined in a module should have a name with a prefix matching the module identifier (or a module directory name), followed with the underscore character. You can use upper-case letters in class names. Example of a correct class name: AbcBlog_ClassName. You can use any characters allowed by PHP for class names after the prefix. For example you can create a class with the following name: AbcBlog_Class_Name.

PHP class files

All PHP classes, including model classes, should be declared in separate files. A PHP class file name should match a name of a class declared in the file, and should be written in lower case. Example of a correct class file name: abcblog_classname.php. This file can contain a PHP class with the following names: AbcBlog_ClassName or AbcBlog_Classname, or other name with any combination of uppper- and lower-case characters.

Also there are some conventions for controller and view file names, but they will be described in the Adding a back-end user interface article.

Database table names

Database table names should be written in lower case and should have prefixes matching a module identifier, followed with the underscore character. Example of a correct table name: abcblog_posts.

Database table column names

Database table column names should be written in lower case with underscore separators. Example of a correct table column name: updated_at.

The primary key column should always be named id.

Continue

Next: Guide to Build a Simple LemonStand Module
Previous: Extending LemonStand
Return to Extending LemonStand