Dit product is onderdeel van Infowijs - een studio met maarschappelijk hart.
  • Getting Started

Creating Controllers

As stated earlier, controllers are separate parts of your module that are called for certain situations, like when a request is made from the API, when your module wishes to extend another module, and so on. Adding a controller is a simple two-step process:

First you add the controller to the ‘controllers’ object in your module.json:


  "controllers": {
    "web": "web/index.php"

Now every time the ‘web’ controller of your module is called, the file at path ‘web/index.php’ will be executed. This is a simple PHP file that has access to the Scholica Module API and can produce results that are shown to the user. A simple ‘web’ controller could look like this:


<h1>Hello <?php echo $this->user->name; ?>!</h1>