TeamCity API wrapper for PHP - usable with or without Laravel 5
A simple PHP wrapper for the API of your TeamCity instance which may or may not be used as a Laravel package.
This package lacks most API functions provided by TeamCity due to the sheer amount of endpoints. If you need any of the missing functions, just add it to the API class and create a pull request.
The package can be installed via composer by running
composer require simon-wessel/teamcity-api
$url = "https://yoururltoteamcity.com/"; $username = "myusername"; $password = "mypassword"; $teamCityApi = new SimonWessel\TeamCityApi\TeamCityApi($url, $username, $password); $builds = $teamCityApi->getBuilds();
The package supports package auto-discovery which has been introduced in Laravel 5.5. If you are using 5.5 or above, you can skip this step.
Otherwise you have to add the Service Provider to the
providers array in your
And if you want to use the Facade, you have to add it to the
aliases array in the same file:
'TeamCity' => \SimonWessel\TeamCityApi\Facade::class,
You will need to configure a TeamCity user account with all permissions for the data and actions you want to access.
You can either set the following environment variables in your
TEAMCITY_URL=https://yoururltoteamcity.com/ TEAMCITY_USERNAME=myusername TEAMCITY_PASSWORD=mypassword
Or alternatively you can publish the package config file and adjust the settings in there. To do this run this command:
php artisan vendor:publish --provider="SimonWessel\TeamCityApi\ServiceProvider"
You will get a new config file
config/teamcity.php with the available settings.
You can access the API with the Facade:
Or calling the Service Provider singleton directly: