Problems with Custom Skeleton Module

I’ve been playing around with the Custom Skeleton Module with an eye toward eventually converting some of my customizations into modules in the hope that they will be easier to maintain through various OpenEMR updates and upgrades. Unfortunately, after negotiating my way through the cloning of the module to the interface/modules/custom_modules folder and then registering, installing and enabling the module I’m left with a system that won’t work. After doing so every menu item that I click on ends up displaying a blank page entitled “Unknown” on the tab. Upon exiting I can’t even log back in again as the login screen is blank as well. Any ideas?

For the record, I’m running Ubuntu 20.4 LTS Server on a virtual machine. It’s a new install running PHP 8.1.2. Could the PHP version be the problem?

1 Like

What does your PHP error logs show? I haven’t tested the module on 8.1.2 but I would assume it works. Most likely you need to dump your composer auto-load as you are getting a class not found exception. Your PHP error logs should give you more details on what is going on.

Thank you. I’ll look into that and report back if/when I find anything. In the meantime, on my base machine (M1 Mac with PHP version 7.4.23) I was able to get things running properly after running the “composer require adunsulag/oe-module-custom-skeleton” command.

Edit: here are the contents added to /var/log/apache2/error.log when I attempt to start OpenEMR -
[Mon Apr 25 07:34:49.286192 2022] [php:error] [pid 32787] [client 10.211.55.2:51483] PHP Fatal error: Uncaught Error: OpenEMR\Modules\CustomModuleSkeleton\GlobalConfig::__construct(): Argument #1 ($globalsArray) cannot be passed by reference in /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php:89\nStack trace:\n#0 /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/openemr.bootstrap.php(23): OpenEMR\Modules\CustomModuleSkeleton\Bootstrap->__construct()\n#1 /var/www/html/openemr/src/Core/ModulesApplication.php(108): include(’…’)\n#2 /var/www/html/openemr/src/Core/ModulesApplication.php(96): OpenEMR\Core\ModulesApplication->loadCustomModule()\n#3 /var/www/html/openemr/src/Core/ModulesApplication.php(70): OpenEMR\Core\ModulesApplication->bootstrapCustomModules()\n#4 /var/www/html/openemr/interface/globals.php(620): OpenEMR\Core\ModulesApplication->__construct()\n#5 /var/www/html/openemr/interface/login/login.php(34): require_once(’…’)\n#6 {main}\n thrown in /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php on line 89
[Mon Apr 25 07:34:50.530159 2022] [php:error] [pid 32785] [client 10.211.55.2:51484] PHP Fatal error: Uncaught Error: OpenEMR\Modules\CustomModuleSkeleton\GlobalConfig::__construct(): Argument #1 ($globalsArray) cannot be passed by reference in /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php:89\nStack trace:\n#0 /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/openemr.bootstrap.php(23): OpenEMR\Modules\CustomModuleSkeleton\Bootstrap->__construct()\n#1 /var/www/html/openemr/src/Core/ModulesApplication.php(108): include(’…’)\n#2 /var/www/html/openemr/src/Core/ModulesApplication.php(96): OpenEMR\Core\ModulesApplication->loadCustomModule()\n#3 /var/www/html/openemr/src/Core/ModulesApplication.php(70): OpenEMR\Core\ModulesApplication->bootstrapCustomModules()\n#4 /var/www/html/openemr/interface/globals.php(620): OpenEMR\Core\ModulesApplication->__construct()\n#5 /var/www/html/openemr/interface/login/login.php(34): require_once(’…’)\n#6 {main}\n thrown in /var/www/html/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php on line 89

Just finished going through the OpenEMR Easy Docker Development Series on YouTube (https://youtube.com/playlist?list=PLFiWG_dDadgQT7zjqvEqbXm1OiuubOVO8)

I setup the dev dockers and cloned the skeleton project resulting in the same conditions the OP describes: blank screens, unable to login.

Here are my steps

  1. Stand up Ubuntu 22.x server on a Hyper-V vm
  2. Install OpenSSH, etc
  3. Install Git, Docker, Docker-compose, Nodejs, npm, and Openemr-cmd
  4. Forked the repo into my environment (Dec 6, 2022)
  5. Clone repo onto server
  6. Run openemr-cmd up in the openemr/docker/development-easy directory
  7. Ate some donuts
  8. Verified that the OpenEMR install is working and added 10 sample patients
  9. Clone skeleton repo into the custom_modules directory
  10. Updated the main composer.json file to add CustomModuleSkeleton namespace to the psr-4 section.
  11. Ran composer dump-autoload
  12. In OpenEMR, Register, Install, Enable skeleton

Per the OP’s follow up post, I tried to run composer require adunsulag/oe-module-custom-skeleton command but get the following error:

composer require adunsulag/oe-module-custom-skeleton
Info from https://repo.packagist.org: #StandWithUkraine

In InitCommand.php line 904:
                                                                                                                                         
  Package adunsulag/oe-module-custom-skeleton has requirements incompatible with your PHP version, PHP extensions and Composer version:  
    - adunsulag/oe-module-custom-skeleton 2.0.0 requires php ^7.1 which does not match your installed version 8.1.2.                     
                                                                                                                                         

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]

The following entry is in my php log

[Thu Dec 08 19:37:29.011199 2022] [php:error] [pid 851] [client 192.168.5.133:62336] PHP Fatal error:  Uncaught Error: OpenEMR\\Modules\\CustomModuleSkeleton\\GlobalConfig::__construct(): Argument #1 ($globalsArray) cannot be passed by reference in /var/www/localhost/htdocs/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php:89\nStack trace:\n#0 /var/www/localhost/htdocs/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/openemr.bootstrap.php(23): OpenEMR\\Modules\\CustomModuleSkeleton\\Bootstrap->__construct()\n#1 /var/www/localhost/htdocs/openemr/src/Core/ModulesApplication.php(110): include('...')\n#2 /var/www/localhost/htdocs/openemr/src/Core/ModulesApplication.php(98): OpenEMR\\Core\\ModulesApplication->loadCustomModule()\n#3 /var/www/localhost/htdocs/openemr/src/Core/ModulesApplication.php(72): OpenEMR\\Core\\ModulesApplication->bootstrapCustomModules()\n#4 /var/www/localhost/htdocs/openemr/interface/globals.php(620): OpenEMR\\Core\\ModulesApplication->__construct()\n#5 /var/www/localhost/htdocs/openemr/interface/modules/zend_modules/public/index.php(60): require_once('...')\n#6 {main}\n  thrown in /var/www/localhost/htdocs/openemr/interface/modules/custom_modules/oe-module-custom-skeleton/src/Bootstrap.php on line 89, referer: http://gharke-priv-dev-docker:8300/interface/main/tabs/main.php?token_main=Xsy6KJ39AZC2hYOKYMLt3P5xqkKzNueTyQHTl2Js

Is this something that is happening in the Docker environment?

I don’t seem to have these problems in my standard LAMP installation. My LAMP is also running on a Hyper-V vm and is running OpenEMR 7.0.0(1)

Appreciate any ideas for me to troubleshoot this issue - I would prefer to work in the docker environment. Thanks.

hi @KenSchae ,

One of the tricks with the dockers is to run the build commands (composer, npm) from within the docker and not outside the docker (for this reason, your server outside the docker does not need nodejs, npm, and composer since these things are done inside the docker where these packages are ready to go). You can run the following openemr-cmd to go into the docker:
openemr-cmd s

Running builds outside the docker can actually cause problems with the easy development environment (poisons your git repo with all the built packages and breaks the autobuilding/autoconfiguration tools of the easy docker development environment). Easy to clean up though (let know if need instructed for this if have problems).

Thank you, that helps a lot. I am new to docker and spending time to really dig into it with and without OpenEMR. These are the types of problems that help me really learn it well.

I think I will stand up a new environment to learn the fundamentals and then work on the learning how to do the cleanup later.

I need to update the skeleton module for the PHP8 version. There’s a problem with passing the globals array by reference which I was doing to isolate the dependency and hopefully if/when OpenEMR introduces a global config option instead of using the globals array it’d be an easy swap. I probably won’t be able to push an update on the skeleton module until Monday.

1 Like

I found that PHP change when I was updating my clearinghouse integration module. It works now with the newest PHP. My module certainly isn’t the “perfect way to do things” I haven’t done PHP since college 20+ years ago. I’m a .net developer. However, here is my module source it might help you get ideas.

This was the change I made, in GlobalConfig.php.

From: public function __construct(array &$globalsArray)
To: public function __construct(array $globalsArray)

1 Like

I updated the module and it should now all be working on PHP8 version with the latest tag (2.0.1).

The command

composer require adunsulag/oe-module-custom-skeleton

Should bring in the latest version.

1 Like

I’m right there with you, .NET developer for years. PHP was always a side hobby, now I’m learning all over again.

Thank you, you’re great looking into this over the weekend.

BTW: The module works like a charm now. :slight_smile:

And Brady was correct too, I was executing the commands in the wrong layer.