title: How to call binance api class in php construtor?
body: <p>I am trying to call binance api class in construct method in my controller so that I can access that api class instance throught entire controller. Problem lies that I need to pass $key and $secret variables to binance class in order to get that object, but I can not do that in construct method. I tried making config.ini file and calling it with parse_ini_file but that returned error that I can not use that function inside class. Here is my code. Any help is appreciated or if someone has other idea on how to make this work.</p>
  <p>controller</p>
  <pre><code>&lt;?php
  
  ini_set('display_errors',1);
  ini_set('display_startup_errors',1);
  require 'vendor/autoload.php';
  
  class BinanceController 
  {
      private $api;
      private $key = 'some long string 1';
      private $secret = 'some long string 2';
  
      $api = new Binance\API($key,$secret); // SOMEHOW I NEED LIKE THIS!!!
  
      public function __construct()
      {
          $this-&gt;api = new Binance\API($this-&gt;key,$this-&gt;secret);
      }
  
      public function getAllBinancePairs()
      {
          $exchangeInfo = $this-&gt;api-&gt;exchangeInfo(); // HERE IS SOURCE OF ERROR!!!
  
          $results = [];
  
          foreach($exchangeInfo['symbols'] as $info) {
              $results[] = $info['symbol']; 
       
          }
  
          json_response($results);
      }
  }
  </code></pre>
  <p>index.php</p>
  <pre><code>&lt;?php
  
  require 'vendor/autoload.php';
  
  $router = new AltoRouter();
  
  $router-&gt;map( 'GET', '/fbinance', function() {
      require __DIR__ . '/fbinance.php';
  });
  
  
  $router-&gt;map('GET','/get-all-binance-pairs', array('c' =&gt; 'BinanceController', 'a' =&gt; 'getAllBinancePairs'));
  
  $match = $router-&gt;match();
  
  if(!isset($match['target']['c']))
  {
      header( $_SERVER[&quot;SERVER_PROTOCOL&quot;] . ' 404 Server Error', true, 404);
  }
  
  
  switch($match['target']['c']) {
      case &quot;BinanceController&quot;: 
          include 'controllers/BinanceController.php';
          if( $match &amp;&amp; is_callable(&quot;BinanceController::&quot; . $match['target']['a']) ) {
              call_user_func_array(&quot;BinanceController::&quot; . $match['target']['a'], $match['params'] ); 
          } else {
              // no route was matched
              header( $_SERVER[&quot;SERVER_PROTOCOL&quot;] . ' 404 Server Error', true, 404);
              exit;
          }
          break;
      default:
          header( $_SERVER[&quot;SERVER_PROTOCOL&quot;] . ' 404 Server Error', true, 404);
          break;
  }
  </code></pre>