42sol/laravel-youtrack-client

1.0.7 2023-11-17 10:25 UTC

This package is auto-updated.

Last update: 2024-10-17 12:42:23 UTC


README

Include service provider in your app

Insert library service provider YouTrackClient\Providers\YouTrackClientProvider::class in your config/app.php file:

'providers' => [
    // other service providers
    YouTrackClient\Providers\YouTrackClientProvider::class,
]

Publish packages resources

This will create config/youtrack.php configuration file.

php artisan vendor:publish --provider="YouTrackClient\Providers\YouTrackClientProvider"

Configure

After publishing package resources you can edit configuration in config/youtrack.php file.

To set your YouTrack instance add to .env variables:

YT_BASE_URL=https://youtrack.example.com               # required
# YT_HUB_URL=https://youtrack.example.com/hub/api/rest # optional
YT_TOKEN="youtrack access token"                       # required

Default routing

If needed, use YouTrackClient\YouTrackRoutes::apply(); to make default library routes, e.g.:

/**
 * This will make routes:
 *  - /yt/projects
 *  - /yt/issues
 *  - ...
 */
Route::prefix('/yt')->group(function () {
    YouTrackClient\YouTrackRoutes::apply();
});

Routes:

  • /projects - get all projects
  • /projects/{id} - get detailed project information by id
  • /projects/{id}/issues - get project issues
  • /projects/{id}/timeTrackingSettings - get project time tracking settings
  • /agiles - get all agile board
  • /agiles/{id} - get detailed agile information by id
  • /issues?query=<filter>&offset=0&limit=50 - get issues by filter
  • /issues/{id} - get detailed issue information by id
  • /organizations - get all organizations
  • /users - get all users

Usage

Manually

use YouTrackClient\YouTrackClient;

$client = new YouTrackClient([
    'baseUrl' => 'https://youtrack.example.com/api',
    'hubUrl' => 'https://youtrack.example.com/hub/api/rest', // optional
    'token' => '<youtrack access token>'
]);

$client->getProjects();

With dependency injection:

use YouTrackClient\YouTrackClient;

class YoutrackTestController extends Controller
{
    private YouTrackClient $client;

    // YouTrackClient will be injected here
    public function __construct(YouTrackClient $client)
    {
        $this->client = $client;
    }

    public function getProjects() {
        return $this->client->getProjects();
    }
}