Mantra how-to guide

How to move a component to other location

When your project gets bigger, usually you need to organize better your components. You can move them to other locations but Mantra should know about it.

03-May-2022
A  A  A 

As your project gets bigger in the number of features, if you follow Mantra Development Principles, you'll need to handle an increasing number of components.

And that's fine, because if you develop components with one (and only one) specific concern, as remembers Single Responsability Principle, then you'll be able to reuse it in other projects or to understand it easier and, thus, get a better maintenabililty of your projects in the long run.

Is a common task to refactor coding design as new requirements are being implemented, but this should include to clean and organize better your assets locations, including your components.

At the time of writing this, Mantra site consists of about a hundred of different components located at five different folders.

Mantra keeps the location (the folder where resides) for each component in its own data model; this is necesary for a faster load of the application when you start it.

What to do when you need to move a component to other location?

You only have to use the core command named as update-components-locations:

$ mantrad update-components-locations

This core command will scan all current components installed to check if they have changed their locations.

If you do so, remember to add this action to your update script in production for the following update.

More core commands at the official documentation.