Zend Framework 2.0 interface not found

Short version

Where is the client class looking for the DispatchableInterface interface?

 class Client implements Libraries\Stdlib\DispatchableInterface 

I am trying to add ZF2 libraries to a CodeIgniter installation. The entire Zend folder is located in:

  /Users/stef/Sites/site_name/application/libraries/ 

In my CI controller, I have

 public function run() { $CI =& get_instance(); $CI->load->library('Zend'); $CI->load->library('Zend/Http/Client'); $client = new Client($url); //Do stuff } 

When I call the run () method, I get a fatal error:

Fatal error: 'Zend\Stdlib\DispatchableInterface' interface was not found in / Users / stef / Sites / site _name / application / libraries / Zend / Http / Client.php on line 27

In the /Zend.php libraries (the file I added, not the ZF part) I have

 function __construct($class = NULL) { // include path for Zend Framework // alter it accordingly if you have put the 'Zend' folder elsewhere ini_set('include_path',ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries/Zend/'); } 

It doesn't look like I set include_path, even if I set dummy values, the fatal error will remain the same. It seems that loading the DispatchableInterface interface does not use include_path.

How can I make Client.php "find" the interface that it is trying to do here:

 class Client implements Libraries\Stdlib\DispatchableInterface 
+4
source share
1 answer

Perhaps the hardest solution:

 set_include_path(get_include_path() . PATH_SEPARATOR . '/Users/stef/Sites/site_name/application/libraries/'); require_once 'Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $loader->register(); 

Then skip the CI->load . And just use new Zend\Http\Client . Also make sure that the dispatch interface is in /Users/stef/Sites/site_name/application/libraries/Zend/Stdlib/DispatchableInterface.php

Update: I noticed now:

 class Client implements Libraries\Stdlib\DispatchableInterface 

What is this class? Is this a Zend class? I assume this is your class. And you add the wrong interface with names. IMO this should be \Zend\Stdlib\DispatchableInterface

+3
source

Source: https://habr.com/ru/post/1434457/


All Articles