Module Dependencies


This guide will help you to understand how we can make sure modules in VaahCMS are dependent on each other.


Step 1:

You need to go to following path in our project:

Step 2:

In this file after scrolling down you will be able to find a function named as dependencies() .

Follow below image for reference:

Step 3:

Basically dependencies function of SetupController.php is called whenever we activate a module.

Here in $response['data']['modules'] variable we need to pass the array of modules.

Suppose you have two modules 1. Travel 2. Sample

Lets consider that Travel module is dependent on Sample module i.e Travel module is of no use without Sample module. Then you need to pass the Sample module as an array in $response['data']'modules' variable.

public static function dependencies()
       $response['success'] = true;
       $response['data']['modules'] = ['Sample'];
       $response['data']['themes'] = [];

       return vh_response($response);

Step 4:

Now if you try to activate the Travel module without activating the Sample module, you will get an error message stating that Sample module is not activated yet.