Welcome Guest, Not a member yet? Register   Sign In
Where to put a PHP Extender Class in CI Framework?
#1

[eluser]Unknown[/eluser]
Hi, I'm just getting started with CI and OO, so apologies is this question is a bit basic...

I need to use a MS SOAP PHP extension class for an application, and was wondering if I could place it in the 'application/libraries/MSSoapClient.php' folder so I could reference when needed. I tried and it didn't work and I'm a bit confused.

Here is the class I would like to reference multiple times:

Code:
class MSSoapClient extends SoapClient {

function __doRequest($request, $location, $action, $version) {
  $namespace = "http://tempuri.org/";
  $request = preg_replace('/<ns :(\w+)/', '<$1  $request, 1);
  $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
  $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
      
  // parent call
  return parent::__doRequest($request, $location, $action, $version);
}
}

...and here is my code in a controller trying to add the library:

Code:
&lt;?php
class Idcs_member_enrollment extends CI_Controller {

public function index(){
  
  $this->load->library('MSSoapClient');

.....

FYI, I'm developing this locally running MAMP server. If I include the MSSoapClient class in the above Idsc_member_enrollment controller, underneath the primary class, it works. I assume this is not proper form. Here's an example of how it works, but would rather learn the right way.

Code:
&lt;?php
class Idcs_member_enrollment extends CI_Controller {

public function index(){
  
  $this->load->library('MSSoapClient');
              
                /* Main code here */
        }
}

class MSSoapClient extends SoapClient {

function __doRequest($request, $location, $action, $version) {
  $namespace = "http://tempuri.org/";
  $request = preg_replace('/<ns :(\w+)/', '<$1  $request, 1);
  $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
  $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
      
  // parent call
  return parent::__doRequest($request, $location, $action, $version);
}
}

Thanks in advance.


Messages In This Thread
Where to put a PHP Extender Class in CI Framework? - by El Forum - 01-30-2013, 06:28 PM
Where to put a PHP Extender Class in CI Framework? - by El Forum - 01-30-2013, 08:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB