Lean Testing PHP SDK
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Lean Testing PHP SDK

Latest Stable Version License

PHP client for Lean Testing API

You can sign up for a Lean Testing account at https://leantesting.com.


  • PHP 5.4 or greater


The library is installed via Composer. To install, simply add it to your composer.json file:

    "require": {
        "cst/leantesting": "2.*"

And run composer to update your dependencies:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

Basic Usage

  • Instantiate the client
$client = new LeanTesting\API\Client\Client();
$client->attachToken('<your token>');

// Listing projects
$projects = $client->projects->all();

// Fetching project bugs
$bugs = $client->projects->find(123)->bugs->all();


  • Get Current Token
  • Attach New Token
  • Generate Authorization URL
$generated_URL = $client->auth->generateAuthLink(
	'DHxaSvtpl91Xos4vb7d0GKkXRu0GJxd5Rdha2HHx', // client id
	'write', // scope
	'a3ahdh2iqhdasdasfdjahf26' // random string
print_r( $generated_URL );
  • Exchange authorization code for an access token
$token = $client->auth->exchangeAuthCode(
	'DHxaSvtpl91Xos4vb7d0GKkXRu0GJxd5Rdha2asdasdx', // client id
	'DpOZxNbeL1arVbjUINoA9pOhgS8FNQsOkpE4CtXU', // client secret
	'JKHanMA897A7KA9ajqmxly', // auth code
print_r( $token );

  • Get User Information
  • Get User Organizations
  • Retrieve An Existing User Organization

  • List All Projects
  • Create A New Project
$new_project = $client->projects->create([
	'name' => 'Project135',
	'organization_id' => 5779
print_r( $new_project->data );
  • Retrieve An Existing Project
  • List Project Sections
  • Adding A Project Section
$new_section = $client->projects->find(3515)->sections->create([
	'name' => 'SectionName'
print_r( $new_section->data );
  • List Project Versions
  • Adding A Project Version
$new_version = $client->projects->find(3515)->versions->create([
	'number' => 'v0.3.1104'
print_r( $new_version->data );
  • List Project Test Cases
  • List Project Test Runs
  • Retrieve Results For Test Run
  • List Project Users
  • Remove A Project User
  • List Bug Type Scheme
  • List Bug Status Scheme
  • List Bug Severity Scheme
  • List Bug Reproducibility Scheme

  • List All Bugs In A Project
  • Create A New Bug
$new_bug = $client->projects->find(3515)->bugs->create([
	'title' => 'Something bad happened...',
	'status_id' => 1,
	'severity_id' => 2,
	'project_version_id' => 123
print_r( $new_bug->data );
  • Retrieve Existing Bug
  • Update A Bug
$updated_bug = $client->bugs->update(123, [
	'title' => 'Updated title',
	'status_id' => 1,
	'severity_id' => 2,
	'project_version_id' => 123
print_r( $updated_bug->data );
  • Delete A Bug

  • List Bug Comments

  • List Bug Attachments
  • Upload An Attachment
$file_path = '/place/Downloads/Images/1370240743_2294218.jpg';
$new_attachment = $client->bugs->find(123)->attachments->upload($file_path);
print_r( $new_attachment->data )
  • Retrieve An Existing Attachment
  • Delete An Attachment

  • List Platform Types
  • Retrieve Platform Type
  • List Platform Devices
  • Retrieve Existing Device
  • List OS
  • Retrieve Existing OS
  • List OS Versions
  • List Browsers
  • Retrieve Existing Browser
  • List Browser Versions

  • Using Filters
$client->projects->find(3515)->bugs->all(['limit' => 2, 'page' => 5]).toArray();
  • Entity List Functions
$browsers = $client->platform->browsers->all()
echo $browsers->total()
echo $browsers->totalPages()
echo $browsers->count()
echo $browsers->toArray()
  • Entity List Iterator When used in foreach() loops, entity lists will automatically rewind, regardless of page filter. After ending the loop, the entity list will NOT revert to first page or the initial instancing page filter setting in order not to cause useless API request calls.
$comments = $client->bugs->find(123)->comments->all(['limit' => 1]);
foreach ($comments as $page) {
	print_r( $page );
  • Entity List Manual Iteration
$comments = $client->bugs->find(123)->comments->all(['limit' => 1]);
echo $comments->toArray();

// Will return false if unable to move forwards
$comments->next();      echo $comments->toArray();

// Will return false if already on last page
$comments->last();      echo $comments->toArray();

// Will return false if unable to move backwards
$comments->previous();  echo $comments->toArray();

// Will return false if already on first page
$comments->first();     echo $comments->toArray();


Need to report a security vulnerability? Send us an email to support@crowdsourcedtesting.com or go directly to our security bug bounty site https://hackerone.com/leantesting.


Install dependencies:

composer install


Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:



Please see CONTRIBUTING for details.