0
$httpAdapter = new \Zend\Http\Client\Adapter\AdapterInterface();

give error -

Fatal error: Cannot instantiate interface Zend\Http\Client\Adapter\AdapterInterface.

closed as too broad by Keyur Shah, Amit Bera, Keyul Shah, mbalparda, Rajeev K Tomy Jul 7 '16 at 4:54

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You cannot interact with an interface except for accessing any defined constants in it or using it for TypeHints. – Keyur Shah Jul 4 '16 at 6:29
  • please give a example how to use it? – Magento2 Devloper Jul 4 '16 at 6:36
  • Why you need this adapter? for curl? – Sohel Rana Jul 4 '16 at 8:51
  • in payment method after success get all data... $res = $this->_postBack($httpAdapter,$this->cgi_url.'/'.'transaccion/' . $this->_request['token'], $header_array, $data); – Magento2 Devloper Jul 4 '16 at 9:00
  • protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter,$url, $header_array, $data) { $result = $this->sendRequest($url, Zend_Http_Client::GET, $header_array); if($result){ return $result; } else{ throw new Exception($error); } } – Magento2 Devloper Jul 4 '16 at 9:02
1

You cannot instantiate an interface, you have to choose a concrete implementation (a class)

The following implementations are built in:

  • Zend\Http\Client\Adapter\Socket
  • Zend\Http\Client\Adapter\Proxy
  • Zend\Http\Client\Adapter\Curl
  • Zend\Http\Client\Adapter\Test

(see: https://framework.zend.com/manual/2.4/en/modules/zend.http.client.adapters.html )

You can instantiate one of these with "new", but usually you would not do that directly, but use the Zend\Http\Client class which takes care of adapter instantiation ("Socket" by default)

Not the answer you're looking for? Browse other questions tagged or ask your own question.