0

I'm working on some helpful method in my entity.

private function setApi($api_address,$api_username,$api_password){

    $this->api_address = $api_address;
    $this->api_username = $api_username;
    $this->api_password = $api_password;
    $this->api_client = new SoapClient($api_address); // error
}

Warning: require(App/Entity/SoapClient.php): failed to open stream: No such file or directory in /zendboilerplate/library/Doctrine/Common/ClassLoader.php on line 148 Fatal error: require(): Failed opening required 'App/Entity/SoapClient.php' (include_path='/zendboilerplate/application/../library:/zendboilerplate/application/../library/Bisna/Application/Resource:/zendboilerplate/library:.:/usr/share/php:/usr/share/pear') in /zendboilerplate/library/Doctrine/Common/ClassLoader.php on line 148 It seems that zend looks for a class declaration (and it doesn't use included classes in php).

Identical error for each "new Class" declaration. Using a my own class included in library everything is ok. (Also tried with @new SoapClient() but no result).

Antonino Bonumore
  • 787
  • 1
  • 13
  • 27
  • Is PHP configured using the `--enable-soap` switch which provides this class? Are you using your own autoloader? – drew010 Jul 07 '12 at 20:22
  • in controller new SoapClient() works well, in library/App/Entity/MyEntity.php causes something wrong. So I think that's not about configuration. – Antonino Bonumore Jul 07 '12 at 20:30
  • I'm using zend boilerplate, I don't know if autoloader could cause that. Where I can check something about autoloader? – Antonino Bonumore Jul 07 '12 at 20:33
  • 1
    Try a breakpoint/debug point in `Zend/Loader/Autoloader.php` in the function `autoload` and see if it is trying to autoload `SoapClient`. That should be the file responsible for autoloading in recent versions of ZF. Something for some reason is making it think to look in `App/Entity/SoapClient.php` for that class. Maybe try putting `var_dump(class_exists('SoapClient', false));` before the call to `new SoapClient` and see what happens. – drew010 Jul 07 '12 at 20:39
  • Doctrine/Common/ClassLoader.php here autoload all classes: public function loadClass($className) { if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) { return false; } require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '') . str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension; return true; } – Antonino Bonumore Jul 07 '12 at 20:58
  • Oh okay so you found that its the Doctrine autoloader that is trying to load that class (incorrectly)? – drew010 Jul 07 '12 at 20:59
  • the doctrine class loader, what's wrong?: http://gamebase.googlecode.com/svn-history/r35/trunk/classes/Doctrine/Common/ClassLoader.php – Antonino Bonumore Jul 07 '12 at 21:23
  • Their autoloader doesn't appear to check if the class exists before trying to load it, it just goes right ahead and tries to include it. Sorry, I don't know much about Doctrine or its autoloader. You may just need to disable it before loading SoapClient for some reason. – drew010 Jul 07 '12 at 21:27

1 Answers1

2

I'm guessing this is namespace related. Try changing the line that is erroring to:

$this->api_client = new \SoapClient($api_address);

that should force it to use the PHP SoapClient instead of the namespace that is presumably declared at the start of the file you're having trouble with.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69