Code Monkey home page Code Monkey logo

youtrack-rest-php's Introduction

PHP YouTrack REST

cog-php-youtrack-rest

Build StyleCI Code Climate Maintainability Releases License

Introduction

YouTrack REST API PHP Client uses PSR-7 (HTTP Message Interface) to connect with JetBrains YouTrack REST API.

Part of the PHP YouTrack SDK.

Contents

Features

Requirements

  • YouTrack >= 3.0 with REST-API enabled (always enabled, by default)
  • PHP >= 8.1
  • Guzzle HTTP Client >= 7.0

Related packages

Share your packages! We are open for Pull Requests!

Frameworks support

PHP YouTrack REST is framework agnostic package and could be easily used in any PHP framework you want.

Framework integrations list

Haven't found your favorite framework in the list? We are open for Pull Requests!

Installation

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require cybercog/youtrack-rest-php

Without framework

Be sure to include the autoloader in your project:

require_once '/path/to/your-project/vendor/autoload.php';

Usage

Usage Documentation

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Testing

Run the tests in terminal with:

composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributors

@antonkomarev
Anton Komarev
@adam187
Adam Misiorny

dmkdev

asteisiunas
@MarcHagen
Marc

PHP YouTrack REST contributors list

Alternatives

PHP

Python

.NET

Java

Feel free to add more alternatives as Pull Request.

License

About CyberCog

CyberCog is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.

CyberCog

youtrack-rest-php's People

Contributors

adam187 avatar antonkomarev avatar ilzrv avatar marchagen avatar pacant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

youtrack-rest-php's Issues

Request options & headers

Goals

  • Building request is very complicated and requires simplification.
  • buildHeaders never accept $options variable, remove param or make it usable.
  • request method $options revert back to $formData and add new $options param which will overwrite HTTP client options.

Refactor authorizers

Goals

  • Tell Authorizers what to do, and don't ask them.
  • Remove authenticate method from Authorizer contract (not it's responsibility).
  • Delegate authentication process to Authenticators.
  • Create factory for Authorizer building since this process is more complicated.

New API proposals will be described below.

Refactor exceptions

  • Stop using *Exception postfix on each exception. Make them more verbose.
  • Cog\Contracts\YouTrack\Rest\Client\Exceptions\ClientException should extend RuntimeException?

Refactor Client

Goals

  • Provide an ability to write HTTP Clint adapters for custom PSR-7 implementations.
  • Separation of concerns.
  • Exceptions should be related to their namespace classes responsibilities.
  • Client version should be part of Client contract.
  • User-Agent headers should be more verbose: CLIENT/VERSION HTTP_CLIENT/VERSION PHP/VERSION.

Wrong Authenticator behavior

Authenticator shouldn't append headers to Client request. Authorizer should do it.

This change will lead us to extend Authenticator contract by adding token method.

API client connection design

Version 1

Token Authenticator

$http = new \GuzzleHttp\Client([
    'base_uri' => 'https://example.com',
]);

$client = new \Cog\YouTrack\Services\YouTrackClient($http, [
    'driver' => \Cog\YouTrack\Authenticators\TokenAuthenticator::class,
    'token' => 'YOUTRACK_API_TOKEN',
]);

Cookie Authenticator

$http = new \GuzzleHttp\Client([
    'base_uri' => 'https://example.com',
]);

$client = new \Cog\YouTrack\Services\YouTrackClient($http, [
    'driver' => \Cog\YouTrack\Authenticators\CookieAuthenticator::class,
    'username' => 'YOUTRACK_USERNAME',
    'password' => 'YOUTRACK_PASSWORD',
]);

Container Binding

$this->app->bind(YouTrackClientContract::class, function () {
    $config = $this->app->make('config');

    $http = new Client([
        'base_uri' => $config->get('youtrack.base_uri'),
    ]);

    $options = $config->get('youtrack.authenticators.' . $config->get('youtrack.authenticator'));

    return new YouTrackClient($http, $options);
});

Conclusion

Pros

  • All drivers has same API.

Cons

  • Authenticator building encapsulated inside YouTrackClient.
  • Violate Single Responsibility Principle.

GET request error

In example for time tracking of issue we refer to the next request
GET /api/issues/{issueID}/timeTracking?{fields}

For GET request we need send params in 'query' key for Guzzle Http, but in function buildOptions we can see that it is impossible to do.
image

In result we got wrong request
image

The solution is to change the $defaultOptions parameter
$defaultOptions = [ 'headers' => $this->buildHeaders() ];
and add additional action for value $options

Guzzle 7

At the moment this module holds us from upgrading to Guzzle 7. Any plans to support it please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.