PHP code example of oveleon / youtrack-api-php

1. Go to this page and download the library: Download oveleon/youtrack-api-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oveleon / youtrack-api-php example snippets


use Oveleon\YouTrack\Client;
use Oveleon\YouTrack\HttpClient\HttpClient;

// Create http client to use.
//  You can write your own adapter and use the HttpClientInterface to use e.g. the Guzzle HttpClient.
//  By default, the HttpClient of Symfony is used.
$httpClient = new HttpClient('https://example.myjetbrains.com', 'perm:your-token');

// Create api client
$api = new Client($httpClient);

// Get issues
$issues = $api->issues()
              ->all();

// Refine the query using the filter method
$issues = $api->issues()
              ->filter('state:resolved')
              ->all();

// Cool, but now we would like to specify the return fields...
$issues = $api->issues()
              ->fields(['summary', 'description'])
              ->filter('state:resolved')
              ->all();

// The query on a specific Project can also be refined in exactly the same way
$issues = $api->issues()
              ->filter('state:unresolved')
              ->project('PROJECT_ID');

// The predefined query `findByProject` does nothing more than define a filter for you (In YouTrack the
// filter is described as `query`), so you could also define the following filter to get the same result
$issues = $api->issues()
              ->filter('project:SampleProject')
              ->all();

// Use pagination...
$issues = $api->issues()
              ->paginate(0, 10)
              ->all();

// And now we use another endpoint
$projects = $api->projects()
                ->all();

// ...

$ composer