Creating a new Module
In this section we will create a new Caffeinated Module called Widgets, and use it to define some /widgets API Endpoints. To create a Caffeinated Module we will use the Laravel Artisan command line interface.
To use Artisan within Elentra ME, it is necessary to navigate to the location where the API is included in Elentra ME. If you are using Docker, you will need to do this from the Docker container.
# log into the Docker container
docker exec -it elentra-developer bash
# navigate to Elenta ME
cd /var/www/vhosts/elentra-1x-me
# navigate to the Elentra API
cd www-root/core/library/vendor/elentrapackages/elentra-1x-api
php artisan module:listThis should return output something like this:
+------+-------------+-------------+----------------------------------------------------------------+----------+
| # | Name | Slug | Description | Status |
+------+-------------+-------------+----------------------------------------------------------------+----------+
| 9001 | Assessments | assessments | API Endpoints for the Entrada Assessments | Enabled |
| 9001 | Logbook | logbook | This module is responsible for Logbook management. | Enabled |
| 9001 | User | user | REST API endpoints for the current user | Enabled |
| 9001 | Notices | notices | REST API Endpoints for Notices | Enabled |
| 9001 | Sandbox | sandbox | Example of a module that integrates into the Entrada frontend. | Enabled |
| 9001 | Locations | locations | Locations REST end point | Enabled |
| 9001 | Admissions | admissions | API Endpoints for the ADM flavor of Entrada | Disabled |
| 9001 | Clinical | clinical | This is the description for the Clinical module. | Enabled |
| 9001 | Events | events | Endpoint for events | Enabled |
| 9001 | Portfolio | portfolio | This module is responsible for Portfolio management. | Enabled |
+------+-------------+-------------+----------------------------------------------------------------+----------+You can get help with Artisan commands by using help:
The Caffeinated Modules package we are using adds support for managing the modules through artisan. Create the Widget module.
This will start a wizard. Version and Description can be whatever you like.
This will create a new directory Widgets under app/Modules, and populate a number of directories and files.

Laravel as a PHP framework can act as an API and a front-end web server. For our purposes we only care about the API, so after creating the Module there is some cleanup to do.
Remove the file
Widgets/Routes/web.phpEdit the file
Widgets/Providers/RouteServiceProvider.phpand remove themapWebRoutes()function

Also remove the reference to
mapWebRoutes()in themap()function

Next we will create a controller and routes for our Widgets.
Last updated