How to include $gibbon

I need to be able to access the $gibbon variable so that I can pass it to a function. I’m not sure how to capture that from the environment?

MarkbookView::__construct() must be an instance of Gibbon\\Core, null given

I need to pass in $gibbon, but my php file doesn’t know what it is.

Hi Qualitymix,

Be sure to include the Gibbon core and you’ll have access to all the global variables. You can do so with the following code (assuming you’re in a module, otherwise update the number of levels of directories it goes up):

include ‘…/…/gibbon.php’;`

This should be at the top of your file, after any use` declarations.

Thank you Sandra. Here is the error I get now:
Uncaught Error: Call to a member function addPsr4() on bool in /var/www/html/gibbon/gibbon.php:67

I think it was because my folder in the module was named sources instead of what that function is expecting… src/ Changing that appears to have fixed that particular issue.

Hi Nate,

src and source are two different things: the first is for source code relating to the module you are in, the second refers to data sources. You definitely want to keep /source as /source in your reporting module, otherwise the data sources will not be locate-able.

Can you let me know what version of PHP you are using? I wonder if you are below the required 7.3?

Thanks,

Ross

Hey Ross!
Back in the office today, so just seeing this. I’m using PHP version 7.4.3

I’ve got some things working so far. Trouble I’m running in to now is trying to actively debug the PHP as I go. I have a console_log function that should spit out stuff to the console, but it doesn’t work.

It exists inside the Markbook.php file in /modules/Reports Template/sources/

I’ve created a variable and am trying to check its contents by spitting it to console. Any suggestions?

Hi Nate,

A useful function for debugging in PHP is print_r(), this will dump a variable out, including arrays and objects. I tend to wrap it in <pre> tags to make it easier to read. Something like:

echo '<pre>';
print_r($variableName);
echo '</pre>';

The console.log() function is for javascript, which in Gibbon is front-end only, so it likely won’t be as useful for debugging any server-side changes.