AsgardCMS – Introduction and Generation of Modules
AsgardCMS offers us the facility to add new modules apart from the existing modules in the application. We can add a new module as per our need and demand for the project. Sometimes our project involves various modules to be added. For example, if you are working on a project for insurance then we need to have modules such as customer, insurance, facilities, etc in which each module covers some specific areas of interest.
The module scaffolder is a command that helps to generate needed modules in a very short period of time giving the developer ease to do things.
In order to generate a new module you need to put the following command in CMD after going to the project folder:
php artisan asgard:module:scaffold
Once you enter this command there are a few questions asked by the system related to the module demanded. The questions asked are:
What is the module name ?
Mention the module in the format as vendor/module name. No dashes should be used while naming the module.
Do you wish to use Doctrine or Eloquent ?
The doctrine uses the old PHP structure only whereas Eloquent has the concepts of ORM that are object-relation-mapping. This tells what kind of entities the developer wishes to generate. You can choose among the two depending on your project requirement. My project required the logic of ORM so I choose the eloquent for the same.
- Enter your desired entities
You can enter all the required entities. They can be N in number, and you can mention all. If you left it blank the mentioned entities will be generated and the next question will come up on the screen.
Enter your desired value objects
As per the development demand, one can enter all the objects required. In case no value object is needed one can skip this by leaving it blank. Once these questions are answered the module is generated. Refer to the screenshot below to understand how module creation works.
By default, the new module generated does not have the permissions, so we have to give it the permissions by going to the user’s section on the page.
In order to provide permissions to the new module, you have to log in to your asgardCMS project. You can refer to this article for understanding how to log in to the project. AsgardCMS – Viewing the created project and the framework
The steps for providing permissions are:
Once you have logged in click on the user section on the page.
Select the Roles dropdown
Select the Admin hyperlink
Select the permissions from the header menu
Select all the permissions for the new module.
Finally, the new module is created.