Skip to main content
page last edited on 10 October 2022

Trivial module

Version: 5.5.0

To create a trivial module, select AuthorId and ModuleId and create a folder with the following contents:

AuthorId - XCExample

ModuleId - SampleModule

<XCart>/modules/XCExample/SampleModule/
/config
main.yaml
install.yaml # fixtures uploaded during the module installation
/docs # changelogs, upgrade notes
/public # resources storage (js, css, design images)
/resources # data required for upgrade hooks
/src # PHP code storage, XCExample\SampleModule\ namespace prefix
/templates # twig templates storage

main.yaml

version: 5.5.0.0
type: common # module type; "common" is the mostly used type, it can also be "skin", "payment", or "shipping".
authorName: 'X-Cart team' # a readable author-name
moduleName: 'Sample Module' # a readable module name
description: 'The sample module' # module's brief description
minorRequiredCoreVersion: 0 # the module minor core version (the 3rd number)
dependsOn: { } # a list of module IDs (in the '{AuthorId}-{ModuleId}' format) with dependencies on this module
incompatibleWith: { } # a list of module IDs (in the '{AuthorId}-{ModuleId}' format) incompatible with this module
showSettingsForm: false # the module settings page availability

install.yaml

Use the following file format to specify import data:

{Model class FQCN}:
{
- directives:
forceInsertCommand: true|false
allowedModel: ''
allowMissingParentInsert: true|false
}
- {field}: {value}
{field}: {value}
...
- {field}: {value}
{field}: {value}
...
...

Sometimes it is required to use additional commands:

  • forceInsertCommand - to create new database objects instead of updating existing ones
  • allowedModel - to create/update a specific model
  • allowMissingParentInsert - to automatically create a parent for a model if it is required

A Trivial Module Sample

A trivial module consists of one file:

<XCart>/modules/XCexample/SampleModule/config/main.yaml

version: 5.5.0.0
type: common
authorName: 'X-Cart team'
moduleName: 'Sample Module'
description: 'The sample module'
minorRequiredCoreVersion: 0
dependsOn: { }
incompatibleWith: { }
showSettingsForm: false

After creating the module, execute the following command to enable it and add it to the list:

./bin/service xcst:rebuild --enable XCExample-SampleModule