[Console] :: SoapClient not Found

(*** SOLVED ***)

(Issue regarded a WAMP configuration setting. See my fourth response.)


I have a working app that uses Soap to connect to an API. Everything is working fine. I can properly connected, make requests, receive requests, etc.

I’m now working on building out the Console part of the application to handle some scheduled tasks. However, when I tried to make a basic connection in my ConsoleCommand, I get the following error:

PHP Error[2]: include(SoapClient.php): failed to open stream: No such file or directory

Not really sure why this is happening. Is there some sublty when running PHP in a console? Are there settings in some .ini file somewhere? As I mentioned, the Soap connection is working perfectly fine for the web-app.

Here is my Console Command (you’ll see it’s quite simple)

class PacingCommand extends CConsoleCommand 


    public function run($args)


        // Preparation

        $date = new DateTime();

        $OAS = new OASApi();


        $date->modify('-1 day');

        $campaignList = $OAS->listCampaigns(array(

            'startDate' =>$date->format('Y-m-d'),

            'endDate' => $date->format('Y-m-d'),

            'IDFilter' => 'IP',

            'status' => '',




And the OAS API wrapper that contains the Soap declarations.

class OASApi {

    private $_SOAPUrl = "***The_URL***";

    private $_client;

    private $_OASUsername = '***';

    private $_OASAccount = '***';

    private $_OASPassword = '***'; 


    //Function to make a call to get the list of campaigns for a given date.


    // "startDate" and "endDate" passed in parameter array. Both in format 'Y-m-d'. 

    // "IDFilter" (string to filter campaign IDs).

    // Function Returns a Simple XML object containing the results of the query. 

    public function listCampaigns($params)


        $adXML = '<AdXML>

                        <Request type="Campaign">

                        <Campaign action="list">




                        <StartDate condition="LE">'.$params['startDate'].'</StartDate>

                        <EndDate condition="GE">'.$params['endDate'].'</EndDate>






        return simplexml_load_string($this->_client->OASXmlRequest($this->_OASUsername, $this->_OASAccount, $this->_OASPassword, $adXML));



    function __construct() {


        try {

            $this->_client = new SoapClient($this->_SOAPUrl);

        } catch (Exception $e) {

            echo "<h2>Exception Error!</h2>";

            echo $e->getMessage();




Did you call the command like this?

cd your-yii-app/protected

yiic pacing


BTW Instantiating SoapClient from ConsoleCommand inherited class worked for me. Perhaps you should inherit your API class from CComponent.

Edit2: On second thought, SoapClient isn’t a Yii class so it has to be something in the PHP environment (like you suggest in the post below).


Thanks for your reply!

Yes, I tired this. Still does not work.

I tried extending my API class to inherit from CConsoleCommand and received the same error.

I tried instantiating the SoapClient from within the run function of PacingCommand and received the same error.

Additionally, I went into my localhost settings (WAMP + Windows 7) and made sure that the php.ini had SOAP and OpenSSL extensions running for both the server settings and the PHP executable settings.


I think the problem is that Yii’s autoloader is trying to look in Components for SoapClient.php class and is (obviously) not finding it there.

Why would the Yii WebApp understand that SOAP is packaged with php and the console thinks differently?

For a test, try the SoapClient instantiation in a plain PHP view script and run it from the command line (no Yii dependencies).

Obviously both ways works for me (on Linux).


Just tested the ConsoleCommand descendant successfully using XAMPPLITE 1.7.3 (on W2k :) )



  1. I made a basic test.php file that looks like this:


//test SOAP connection

$OAS = new SoapClient("***THE_URL***");


//Test to see if other PHP classes are inclulded.

$today = new DateTime();


  1. test.php worked in my Web Browser.

  2. test.php DID NOT work in my console application. The error I received: PHP Fatal error: Class ‘SoapClient’ not found in C:\…\test.php

  3. DateTime class loaded without error.

It must be a server problem, then. Any suggestions? Ugh. I just don’t understand why the PHP console is behaving differently than the PHP executable used for the WAMP server.

(thanks for all your help, Tommy. I really appreciate it).


The issue related to WAMP. On top of the PHP.INI file there is a "PHP Configuration" file that needs to be set. It looks identical to the PHP.INI files. I just removed the semicolons next to SOAP and OpenSSL and everything works.

Thank you for your help. Despite the issue being about configuration, your support with debugging really helped isolate the issue.

Thanks again!