Answers.Body: <p>Ok, so it turns out I was kinda doing something wrong...</p>
  
  <p>What I needed was a simple <strong><code>\</code></strong> prefix:</p>
  
  <p><code>
      \Civi::log()-&gt;info('Hello, log!');
  </code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-04T23:34:54.930Z
Answers.Text: The CRM* classes also seem to need a leading "\" too
Answers.UserDisplayName: ErichBSchulz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-04T12:43:55.213Z
Answers.LastActivityDate: 2017-02-04T12:43:55.213Z
Answers.UserDisplayName: ErichBSchulz
Body: <p>I'm trying to use the <code>Civi</code> class to debug an extension with build kit,
  but after I add this line:</p>
  
  <pre><code>   `Civi::log()-&gt;info('Hello, log!');` 
  </code></pre>
  
  <p>to my class I get:</p>
  
  <p><code>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</code></p>
  
  <p>I feel like this ought to work out of the box... am I doing something wrong?</p>
  
  <p>This feels like a variant of <a href="https://civicrm.stackexchange.com/questions/16418/class-naming-and-namespaces-best-practice-as-an-extension-author">this</a> and <a href="https://civicrm.stackexchange.com/questions/15810/does-class-autoloading-not-work-in-standalone-phpunit-testing">this</a> question ... but different in that I'm looking for the pattern to call a core class</p>
  
Tags: <civicrm-buildkit><unit-testing><phpunit><autoloading>
Title: class Civi not found
ThreadText: # class Civi not found
  
  (Asked by: username_0 on 2017-02-04)
  
  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
  
  **Tags:** civicrm-buildkit, unit-testing, phpunit, autoloading
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-02-04. Score: 2
  
  Ok, so it turns out I was kinda doing something wrong...
  
  What I needed was a simple **`\`** prefix:
  
  `\Civi::log()->info('Hello, log!');`
  
  > **Comments:**
  > **username_0**: The CRM* classes also seem to need a leading "\" too  
  
  ---
  
  