leanix/leanix-sdk-php

SDK for PHP to access leanIX REST API

v1.3.1 2014-08-22 09:01 UTC

README

leanIX API version v1, https://developer.leanix.net

Overview

This SDK contains wrapper code used to call the leanIX REST API from PHP.

The SDK also contains two simple examples. The code in samples/ServicesTest.php demonstrates the basic use of the SDK to read Applications from the leanIX Inventory. The code in samples/ProjectsTest.php demonstrates the basic use of the SDK for Projects in leanIX.

Prerequisites

This SDK makes use of PHP namespaces, and as such requires PHP 5.3 or later. Please head to http://www.php.net to download the latest version.

In order to use the code in this SDK, the REST API needs to be activated in your workspace and you need your personal API Key. When you are logged in to leanIX, please go to your profile (click on the user icon in the top menu). You find a menu entry called "API / 3rd party apps". If the REST API is activated, you can generate an API Key here.

You can find the leanIX REST API documentation here https://developer.leanix.net. The documentation is interactive - if you are logged in to your workspace and the REST API is activated, you can try out every function directly from the documentation.

Installing SDK using Composer

Using Composer is one of the options to install LeanIX SDK for PHP.

  1. Add "leanix/leanix-sdk-php" as a dependency in your project's composer.json file.

    {
        "require": {
            "leanix/leanix-sdk-php": "1.3.*"
        }
    }
  2. Download and install Composer.

    curl -s "http://getcomposer.org/installer" | php

  3. Install your dependencies.

    php composer.phar install

  4. Require Composer's autoloader by adding the following line to your code's bootstrap process.

    require '/path/to/sdk/vendor/autoload.php';

Usage

In order to use the SDK in your PHP application, you can use the autoloader which automatically loads required classes from the leanIX SDK.

require_once(dirname(__FILE__)."/../src/leanix/api/autoload.php");

You need to instantiate a leanIX API Client. Here you define the URL to the REST API of your workspace. Please replace demo with the name of your workspace. Also here you need to provide the Api-Key.

$apiClient = new LeanIX\Api\ApiClient();
$apiClient->basePath = "https://app.leanix.net/demo/api/v1";
$apiClient->apiKey = "31c7cfa0b5cb755f4c7f146c92d0ad6b";

You can then use the API class to execute functions. For each Fact Sheet in leanIX there is one API class, e.g. for the Fact Sheet "Application" the API class is called ServicesApi. To print the names of all applications which match the full-text search of "design", you could do the following:

$servicesApi = new LeanIX\Api\ServicesApi($apiClient);
$services = $servicesApi->getServices(false, "design");
foreach ($services as $service)
{
    echo $service->name."\r\n";
}

Update SDK

Go into folder codegen and execute

mvn package

Thank You

This API made use of the swagger-* libraries which help you to describe REST APIs in an elegant way. See here for more details: https://github.com/wordnik/swagger-codegen

Copyright and license

Copyright 2014 LeanIX GmbH under the MIT license.