Answers.Body: <p>I found the answer in the docs here: <a href="https://docs.civicrm.org/dev/en/latest/framework/filesystem/#tip-programmatic-lookup_1" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/framework/filesystem/#tip-programmatic-lookup_1</a></p>
  
  <p>You can use the following: </p>
  
  <pre><code>Civi::paths()-&gt;getPath("[civicrm.root]/.")
  </code></pre>
  
  <p>or </p>
  
  <pre><code>global $civicrm_root;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-16T17:55:39.000Z
Answers.LastActivityDate: 2018-04-16T17:55:39.000Z
Answers.UserDisplayName: Sleewok
Body: <p>I'm working on an extension and I need to include a PHP file that is in the civicrm module root dir. Is there a way to get this directory through PHP? I need it to work for all CMS, not just Drupal.</p>
  
  <p>Thanks!</p>
  
Tags: <php>
Title: How to get CiviCRM root via PHP?
ThreadText: # How to get CiviCRM root via PHP?
  
  (Asked by: username_0 on 2018-04-16)
  
  I'm working on an extension and I need to include a PHP file that is in the civicrm module root dir. Is there a way to get this directory through PHP? I need it to work for all CMS, not just Drupal.
  
  Thanks!
  
  **Tags:** php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-04-16. Score: 4
  
  I found the answer in the docs here: <https://docs.civicrm.org/dev/en/latest/framework/filesystem/#tip-programmatic-lookup_1>
  
  You can use the following:
  
  ```
  Civi::paths()->getPath("[civicrm.root]/.")
  
  ```
  
  or
  
  ```
  global $civicrm_root;
  
  ```
  
  
  ---
  
  