Basic concepts

Authentication

The first lines in your PHP code should be used to create the Webservices object.

We suggest using this method:

$this->ws = OKMWebServicesFactory::build(host, user, password);

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
use Httpful\Exception\ConnectionErrorException;
use openkm\exception\AccessDeniedException;
use openkm\exception\PathNotFoundException;
use openkm\exception\RepositoryException;
use openkm\exception\DatabaseException;
use openkm\exception\UnknowException;

class Example {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetAppVersion() {
        try {            
            $appVersion = $this->ws->getAppVersion();
            var_dump($appVersion);
        } catch (AccessDeniedException $ade) {
            var_dump($ade);
        } catch (PathNotFoundException $pnfe) {
            var_dump($pnfe);
        } catch (RepositoryException $re) {
            var_dump($re);
        } catch (DatabaseException $de) {
            var_dump($de);
        } catch (UnknowException $ue) {
            var_dump($ue);
        } catch (ConnectionErrorException $cee) {
            var_dump($cee);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$example = new Example();
$example->testGetAppVersion();

?>

Also is possible doing the same from each API class implementation.

We do not suggest this way.

For example with this method:

$this->repository = new RepositoryImpl(self::HOST, self::USER, self::PASSWORD);

<?php

include '../src/openkm/OpenKM.php';

use openkm\impl\RepositoryImpl;
use openkm\OpenKM;
use openkm\bean\AppVersion;
use Httpful\Exception\ConnectionErrorException;
use openkm\exception\AccessDeniedException;
use openkm\exception\PathNotFoundException;
use openkm\exception\RepositoryException;
use openkm\exception\DatabaseException;
use openkm\exception\UnknowException;

class Test {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $repository;

    public function __construct() {
        $this->repository = new RepositoryImpl(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetAppVersion() {
        try {            
            $appVersion = $this->repository->getAppVersion();
            var_dump($appVersion);
        } catch (AccessDeniedException $ade) {
            var_dump($ade);
        } catch (PathNotFoundException $pnfe) {
            var_dump($pnfe);
        } catch (RepositoryException $re) {
            var_dump($re);
        } catch (DatabaseException $de) {
            var_dump($de);
        } catch (UnknowException $ue) {
            var_dump($ue);
        } catch (ConnectionErrorException $cee) {
            var_dump($cee);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$test = new Test();
$test->testGetAppVersion();

?>

Accessing API

OpenKM API classes are under com.openkm package, as can shown at this javadoc API summary.

At main url http://docs.openkm.com/javadoc/ you'll see all available javadoc documentation.

At the moment of writing this page the actual OpenKM version was 6.4.22 what can change on time.

There is a direct correspondence between the classes and methods into, implemented at com.openkm.api packages and available from SDK for PHP.

OpenKM API classes:

OpenKM API classDescriptionSupportedImplementationInterface

OKMAuth

Manages security and users. For example add or remove grants on a node, create or modify users or getting the profiles.

Yes

AuthImpl.php

BaseAuth.php

OKMBookmark

Manages the user bookmarks.

No

   

OKMDashboard

Manages all data shown at dashboard.

No

   

OKMDocument

Manage documents. For example creates, moves or deletes a document.

Yes

DocumentImpl.php

BaseDocument.php

OKMFolder

Manages folders. For example create, move or delete a folder.

Yes

FolderImpl.php

BaseFolder.php

OKMMail

Manages mails. For example creates, moves or deletes a mails.

Yes

MailImpl.php

BaseMail.php

OKMNote

Manages notes on any node type. For example creates, edits or deletes a note on a document, folder, mail or record.

Yes

NoteImpl.php

BaseNote.php

OKMNotification

Manages notifications. For example add or remove subscriptions on a document or a folder.

No

NotificationImpl.php

BaseNotification.php

OKMProperty

Manages categories and keywords. For example add or remove keywords on a document, folder, mail or record.

Yes

PropertyImpl.php

BaseProperty.php

OKMPropertyGroup

Manages metadata. For example add metadata group, set metadata fields.

Yes

PropertyGroupImpl.php

BasePropertyGroup.php

OKMRecord

Manages records. For example create, move or delete a record. 

Yes

RecordImpl.php

BaseRecord.php

OKMRelation

Manages relations between nodes. For example create a relation ( parent-child ) between two documents.

Yes

RelationImpl.php

BaseRelation.php

OKMRepository

A lot of stuff related with repository. For example get the properties of main root node ( /okm:root ).

Yes

RepositoryImpl.php

BaseRepository.php

OKMSearch

Manages search feature. For example manage saved queries or perform a new query to the repository.

Yes

SearchImpl.php

BaseSearch.php

OKMStats

General stats of the repository.

No

   

OKMTask

Manages task. For example create a new task.

No

   

OKMUserConfig

Manages user home configuration.

No

   

OKMWorkflow

Manages workflows. For example executes a new workflow.

Yes

WorkflowImpl.php

BaseWorkflow.php

Class Hierarchy

Packages detail:

NameDescription

com.openkm

The  openkm.OKMWebservicesFactory that returns an openkm.OKMWebservices object which implements all interfaces.

$this->ws = OKMWebServicesFactory::build(host, user, password);

openkm.bean

Contains all classes result of unmarshalling REST objects.

openkm.definition

All interface classes:

  • openkm.definition.BaseAuth
  • openkm.definition.BaseDocument
  • openkm.definition.BaseFolder
  • openkm.definition.BaseMail
  • openkm.definition.BaseNote
  • openkm.definition.BaseProperty
  • openkm.definition.BasePropertyGroup
  • openkm.definition.BaseRecord
  • openkm.definition.BaseRelation
  • openkm.definition.BaseRepository
  • openkm.definition.BaseSearch
  • openkm.definition.BaseWorkflow

openkm.impl

All interface implementation classes:

  • openkm.impl.AuthImpl
  • openkm.impl.DocumentImpl
  • openkm.impl.FolderImpl
  • openkm.impl.MailImpl
  • openkm.impl.NoteImpl
  • openkm.impl.PropertyGroupImpl
  • openkm.impl.PropertyImpl
  • openkm.impl.RecordImpl
  • openkm.impl.RelationImpl
  • openkm.impl.RepositoryImpl
  • openkm.impl.SearchImpl
  • openkm.impl.WorkflowImpl

openkm.util

A couple of utilities.

openkm.exception

All exception classes.