rest - PHP hangs on a loop and never makes Request -


i have restful api need inteact using curl. have created wrapper class has static function curl code.

class apiinvoke {      public static function execute($username, $password, $endpoint, $data = array(), $options = array())     {        //rest of curl code goes here.....     }  } 

i created class call static apiinvokve class method execute api call. below consumer class apiinvoke class above.

require "api_invoke.php"

 class flowgearconnect  {      //properties go gere      public function getresults($model, $workflow, $data)     {         $endpoint = $this->getendpoint($model, $workflow);         $results = array();         if(!is_null($endpoint)){            $results = apiinvoke::execute('username', 'password', $endpoint, $data array('timeout' => 30));        }        return $results;     }     //....  } 

then have parentclass class create instance of flowgearconnect object made avalable sub-classes. however, subclasses are processed inside same parent class.

class parentclass {   private $flowgear;    public function init()   {      $this->flowgear = new flowgearconnect(); //assuming has been required somewhere   } } 

then may have childclassa , childclassb extends parentclass. vartue of child classes extending parent class have access instance of $this->flowgear object because below how flowgearconnect class used:

class childclassa {    public function getresults()   {     $results = $this->flowgear->getresults('child_a', 'latestevents', array());    }   } 

childclassb has same function or rather exact except might responsible getting list of orders example.

how these child classes processed inside parent class depicted below:

 //a function inside parentclass process childclassa , childclassb  public function processmodules()  {    $modules = $request->getmodules();      foreach($modules $module){        require_once "modules/' . $module;        $module = new $module();       $module ->getresults();    } } 

something along these lines not right.... extending class creates instance of class used child classes. somewhere somehow not right here , guess has facy not using singgleton. if new how curl concerned.

stupid of me ever thought never able create 1 instance of curl object rayhan’s http client class (http://raynux.com/blog/2009/06/13/http-client-class-for-php-development/).

basically wanted create curl singleton class such not have instances of same object created on , on again.

below skeleton of how went achieve this:

class flowgear {   static private $_instance;    //rest properties here...     public function __cosntsruct()   { $this->_token = $this->_username .':'. $this->_passoword; }    public function execute()   {     //call class handles actual api invocation passing relevant data   }    static public function &getinstance()   {     if(self::$_instance == null){        self::$_instance = new self;      }      return self::$_instance;   } } 

then single instance of class calling flowgear::getinstance();


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -