Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chriss39's avatar

Add outside library package

I am trying to add Cloud Scorm library package to easily use cloud scorm api. I have added it to /app/classes/scorm folder. I then require_once in the config.php file from that folder which will call in a bunch of other files apart of the library. The issue I seem to be running into is the library sets an object named $CFG. Then in a method I will set global $CFG but when I try to call anything from $CFG i get a non object error. If I do a dd on CFG right after the global command it is null.

I have a hack work around where I just do a curl call to scorm folder I put in public but I know that is very bad practice.

I did not post any code as there is a lot in the library package and more in theory question.

What is bet way to include an outside library package and in this case use any objects or functions that package creates.

Thanks

0 likes
5 replies
ejdelmonico's avatar

You can make a laravel package that wraps the non-laravel package for easy use.

chriss39's avatar

Thanks guys I will give that a try and see how it goes.

chriss39's avatar

I noticed I can load this is composer which I did and did composer update and dumpautoload. https://packagist.org/packages/droath/scormcloud-php-library

I have done that but not sure how I call any of the classes.

I have an initial section where I am setting up an object and make a call to one of the classes like this.

$CFG->scormcloudorigin = ScormEngineUtilities::getCanonicalOriginString('Test', 'Course', 'Version 2.0');

and it is failing out. I know I need to tell the the controller to use it but not sure how. I tried

 use vendor\droath\scormcloud-php-library\src; 

but that failed out. How to I include namespace for the package?

chriss39's avatar

Think I figured it out looks like a ScormEngineService and ScormEngineUtilities were loaded so I can just use those.

Thanks

Please or to participate in this conversation.