nepda / youtrack-client
A PHP YouTrack client library
Installs: 465 696
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 6
Forks: 42
Open Issues: 1
Requires
- php: >=5.4
- ext-json: >=1
- ext-simplexml: *
- lib-curl: >=7
Requires (Dev)
- phpunit/dbunit: >=1.2
- phpunit/php-invoker: *
- phpunit/phpunit: 5.*
- phpunit/phpunit-selenium: >=1.2
- phpunit/phpunit-story: *
- dev-master
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.9
- v1.7.8
- v1.7.7
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.10
- v1.0.9
- v1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.1
- dev-php-7.1-test
- dev-low-php-test
- dev-php7-test
This package is auto-updated.
Last update: 2020-07-12 09:14:04 UTC
README
Attention! This library is based on the now-deprecated REST API for YouTrack. jetBrains has release a new version of their REST API. May be I'll create a new version of this library for the new API.
The bugtracker YouTrack provides a REST-API. Because a lot of web applications are written in PHP I decided to write a client library for it. To make it easier for developers to write connectors to YouTrack.
The initial development was sponsored by Telematika GmbH. The current development is made by nepda.
The source of this library is released under the BSD license (see LICENSE for details).
Requirements
- PHP >= 5.4 (Tested with >= 5.6, Travis runs tests with
5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3 and 7.4) - curl
- simplexml
- json
- YouTrack 3.0+ with REST-API enabled (currently, the production system runs with YouTrack 2019.1)
Changelog
Please look into CHANGELOG for a list of the past releases.
Usage
With permanent token
Please look into the YouTrack documentation on how to create such a permanent token.
<?php require_once("YouTrack/Connection.php"); $youtrack = new \YouTrack\Connection("http://example.com", "perm:*****", null); $issue = $youtrack->getIssue("TEST-1"); // ...
The $password
parameter has to be null
for permanent token login. This feature is dirty and will be fixed in version
2.*.
With deprecated username/password login
<?php require_once("YouTrack/Connection.php"); $youtrack = new \YouTrack\Connection("http://example.com", "login", "password"); $issue = $youtrack->getIssue("TEST-1"); // ...
See ./examples
folder for more usage examples.
Usage with ZF2 ZendSkeletonApplication
In your /init_autoloader.php
<?php // ... snip if ($zf2Path) { if (isset($loader)) { $loader->add('Zend', $zf2Path); } else { include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array( 'Zend\Loader\StandardAutoloader' => array( 'autoregister_zf' => true, 'namespaces' => [ // add this 'YouTrack' => 'vendor/YouTrack' // ... ], // ... ) )); } } // ... snip
From now on you can use YouTrack-Client-PHP-Library from any file in you ZF2-App.
<?php // ... // example use YouTrack\Connection as YouTrackConnection; class ExampleController extends AbstractActionController { public function anyAction() { $youtrack = new YouTrackConnection("http://example.com", "login", "password"); $issue = $youtrack->getIssue("TEST-1"); // ... } }
Standalone setup with composer
Run the following commands to install composer and youtrack-client.
mkdir my-youtrack-project cd my-youtrack-project php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" php composer.phar require nepda/youtrack-client
(Please checkout the latest composer setup on their page)
Create a ./my-youtrack-project/client.php
file with content:
<?php define('YOUTRACK_URL', 'https://*your-url*.myjetbrains.com/youtrack'); define('YOUTRACK_USERNAME', '***'); define('YOUTRACK_PASSWORD', '***'); require_once 'vendor/autoload.php'; try { $youtrack = new YouTrack\Connection( YOUTRACK_URL, YOUTRACK_USERNAME . 'invalid', YOUTRACK_PASSWORD ); echo 'Login correct.' . PHP_EOL; $issue = $youtrack->getIssue('TEST-123'); // Now you can work with the issue or other $youtrack methods } catch (\YouTrack\IncorrectLoginException $e) { echo 'Incorrect login or password.' . PHP_EOL; }
$issue = $youtrack->getIssue('TEST-123');
// Now you can work with the issue or other $youtrack methods
} catch (\YouTrack\IncorrectLoginException $e) { echo 'Incorrect login or password.' . PHP_EOL; }
With this simple setup you're ready to go.
## Tests
The testsuite depends on PHPUnit. You can install it with `composer.phar`:
```sh
curl -sS https://getcomposer.org/installer | php --
php composer.phar install
The unit tests are incomplete but you can run them using phpunit
like this:
./vendor/bin/phpunit ./test
Contributors
(and more: https://github.com/nepda/youtrack-client/network/members)