1

I'm trying to use the Civi class to debug an extension with build kit, but after I add this line:

   `Civi::log()->info('Hello, log!');` 

to my class I get:

ampuser@58e3a823b9ee:/opt/buildkit/build/dmaster/sites/default/files/civicrm/ext/api4$ phpunit4 PHP Fatal error: Class 'Civi\API\V4\Civi' not found in /opt/buildkit/build/dmaster/sites/default/files/civicrm/ext/api4/Civi/API/V4/Action.php on line 117

I feel like this ought to work out of the box... am I doing something wrong?

This feels like a variant of this and this question ... but different in that I'm looking for the pattern to call a core class

1 Answer 1

2

Ok, so it turns out I was kinda doing something wrong...

What I needed was a simple \ prefix:

\Civi::log()->info('Hello, log!');

1
  • The CRM* classes also seem to need a leading "\" too Commented Feb 4, 2017 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.