Questions from an OpenEMR newbie

(Zero) #1

First… I want to say sorry for my bad English.
I spent the last 2 weeks reading the code and OpenEMR forum, especially the posts about PHPunit, code design, and architecture design.

I have 2 questions:

The most obvious thing is that all the code is entangled in $ global, even the newest part (src / *). The consequence is that we have a low level of testability (not impossible, but hard).
In the ongoing modernization process, is there a plan to eliminate, isolate or minimize the use of $ GLOBAL?

Second question:
In the application, there are 2 containers zend/service-manager and symfony/container (), but they seem to be unused there is a reason?
Maybe zend is only for plugin and module, but symfony?


(Brady Miller) #2

hi @zerai ,

@adunsulag will likely be most helpful on the zend/service-manager and symfony/container use.

Regarding the modernization, would it make sense to test API since that is the most modern part of codebase? I am working on a PR that expands the build (does a complete build/deployment now) to open door for this. Getting away from globals would be very tough if not impossible; it’s what pieces things together and ensures proper auth.


(Brady Miller) #3

forgot to post the PR to what I discussed above. here it is:

(Stephen Nielson) #4


There are indeed two service containers, both have been there for a while. zend/service-manager is only used in the creation and use of Zend modules. The OpenEMR modules function similar in nature to a wordpress plugin system with modules that can be turned on and off through the module manager.

The Symfony container was in the codebase but was pretty much unused except for the instantiation of the Symfony event dispatcher which also was unused.

However, we recently revamped the modules system so that you can have both zend modules utilizing the zend MVC (which is a requirement due to several large OpenEMR installations using zend modules), as well as non-zend modules that just hook into core code using the pub/sub Symfony event dispatcher. Very few people understood or even wanted to interact with anything zend based despite its historical use. We leveraged the Symfony Container for that purpose.

For testing purposes I would focus on the symfony container as that is the main one we will be using in the future. Vendors and other module developers should be responsible for testing their own modules.

I agree with @brady.miller that getting away from $Globals will be a tough refactor. Long term I would like OpenEMR to get there so we can improve the testability of the system as I agree it makes testing hard to do. Authorization and other pieces can be handled with a service container instead of using Globals which would vastly simplify our testing problems.