api/MarkLogic/MLPHP/RESTClient.php
public function installExtension($resource, $params, $filename)
    {
        if (!isset($params["provider"])) {
            $params["provider"] = 'MLPHP';
        }

        $path = __DIR__ . DIRECTORY_SEPARATOR . "xquery" . DIRECTORY_SEPARATOR . $filename;

        $body = file_get_contents($path);
        $key = serialize(array($this->host, $this->port, $resource, $params, $body));
        if (array_key_exists($key, self::$extension_cache)) {
            return;
        }
        $this->logger->debug("installExtension");
        $method = 'put';
        $headers = array(
            'Content-type' => 'application/xquery'
        );
        $request = new RESTRequest($method, $resource, $params, $body, $headers);
        $this->put($request);
        self::$extension_cache[$key] = 1;
    }
public function installExtension($resource, $params, $filename)
    {
        if (!isset($params["provider"])) {
            $params["provider"] = 'MLPHP';
        }

        $path = __DIR__ . DIRECTORY_SEPARATOR . "xquery" . DIRECTORY_SEPARATOR . $filename;

        $body = file_get_contents($path);
        $key = serialize(array($this->host, $this->port, $resource, $params, $body));
        if (array_key_exists($key, self::$extension_cache)) {
            return;
        }
        $this->logger->debug("installExtension");
        $method = 'put';
        $headers = array(
            'Content-type' => 'application/xquery'
        );
        $request = new RESTRequest($method, $resource, $params, $body, $headers);
        $this->put($request);
        self::$extension_cache[$key] = 1;
    }
Install a REST API XQuery extension

@param $resource URL
@param $params resource parameters (adds in provider=MLPHP if provider not set)
@param $filename file system name of contents of the XQuery module.