Mantra how-to guide

Add default components

Any Mantra project expects you to indicate default components to run them in a fresh installation

08-Mar-2022
A  A  A 

Between all properties that defines a Mantra project somehow at mantraconfig.json file, "DefaultComponents" is important.

How Mantra knows which components to install when you run a new project just downloaded o when you install a new development environment for your working project?

Mantra expects to find in "DefaultComponents" property an array with the components that should be installed when you run install command:

$ mantrad install

Obviously, all those components should be located at the folders located at "ComponentsLocations" property of mantraconfig.json

Each time you add a new component to the project you are working in, if it is part for the base project, you need to add it to "DefaultComponents"; by doing so, you can run a fresh and empty installation of that project in any new development environment.

On the other hand, once you have your project in production, in that environment you only run migrations and updates, and "DefaultComponents" is ignored in that environment.

Just an example of "DefaultComponents" property for a real project (this site):

"DefaultComponents": [
      "aboutus",  "admin",  "analytics", "apiextend", "articles", "blackmailslist",
      "blackipslist", "campaign", "cookieswarning", "contact", "content",
      "contentnodes", "compressresponses", "currentyear", "date",
      "dbremoveolder", "deltatohtml", "download", "dynamicschema",
      "eventasync", "extractfile", "files", "footer", "forms",
      "generalassets", "googleanalytics", "hdlsecurity", "hdltasks",
      "hdlutils", "highlight", "htmlminifier", "invite", "landing",
      "licenses", "logs", "logos", "mantraapiajax", "mailer",
      "mailertest", "mailsubscriber", "mailtouser", "maintenancemode",
      "mantrademosadmin", "mantrademos", "mantradoc",
      "mantrajspublicapi", "mantrarepoinfo", "marketplace",
      "marketplacecomponent", "marketplacedownload", "marketplaceproject",
      "master", "menu", "messageview", "messagetouser",
      "multilanguage", "mysqlbackup", "oldfilesremover",
      "pager", "payments", "popupmessage", "pricing",
      "redirect", "roles", "simplecache", "search", "security",
      "simplenoticemessage", "simplenoticemessageadmin",
      "share", "seo", "stats", "switchbootstrap", "swr",
      "tasks", "tempcache", "text-editor", "resourceminifier",
      "userdownloads", "userlanding", "usermessages",
      "usernotifications", "users", "webassets", "workflows" ],

As you can see, a Mantra application is based on a number components (expected to be samll) with specific functionality and responsabilities.

Tip: to locate easily the components names at DefaultComponents property, try to write them in alphabetical order.