title: How to access Joomla protected property?
body: <p>I have tried this and it's working:</p>
  
  <pre><code>&lt;?php
  define( '_JEXEC', 1 );
  define( 'DS', DIRECTORY_SEPARATOR );
  define( 'JPATH_BASE', dirname(__FILE__).DS."../apitest/");
  
  require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
  require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
  require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
  
  $conn = JDatabase::getConnectors();
  
  print_r($conn);
  ?&gt;
  </code></pre>
  
  <p>However, when I tried this:</p>
  
  <pre><code>&lt;?php
  define( '_JEXEC', 1 );
  define( 'DS', DIRECTORY_SEPARATOR );
  define( 'JPATH_BASE', dirname(__FILE__).DS."../apitest/");
  
  require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
  require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
  require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
  
  $conn = JDatabase::$connection;
  
  print_r($conn);
  ?&gt;
  </code></pre>
  
  <p>It returns:</p>
  
  <pre><code>Fatal error: Cannot access protected property JDatabase::$connection in C:\xampp\htdocs\apitest1\index.php on line 10
  </code></pre>
  
  <p>How can access $connection variable?</p>