Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

👷 Async first TravisCI PHP API Client

License

NotificationsYou must be signed in to change notification settings

php-api-clients/travis

Repository files navigation

Build StatusLatest Stable VersionTotal DownloadsCode CoverageLicensePHP 7 ready

Install

To install viaComposer, use the command below, it will automatically detect the latest version and bind it with^.

composer require api-clients/travis

Usage

The client needs two things, the ReactPHP event loop, and optionally an authentication token. Once you created the client you can call theuser method to show the currently authenticated user.

useReact\EventLoop\Factory;useApiClients\Client\Travis\AsyncClient;useApiClients\Client\Travis\Resource\UserInterface;usefunctionApiClients\Foundation\resource_pretty_print;$loop = Factory::create();$client = AsyncClient::create($loop,'your travis key from https://blog.travis-ci.com/2013-01-28-token-token-token/');$client->user()->then(function (UserInterface$user) {resource_pretty_print($user);});$loop->run();

Results stream

The above example used a promise, when there is more then one result an observabe is returned instead.RxPHP is used for the observables. This means you can apply a huge list of methods to the stream of results

useReact\EventLoop\Factory;useApiClients\Client\Travis\AsyncClient;useApiClients\Client\Travis\Resource\BroadcastInterface;usefunctionApiClients\Foundation\resource_pretty_print;$loop = Factory::create();$client = AsyncClient::create($loop,'your key');$client->broadcasts()->subscribe(function (BroadcastInterface$broadcast) {resource_pretty_print($broadcast);});$loop->run();

Synchronous usage

The synchronous client works nearly the same as the asynchronous, infact it wraps the asynchronous client to do all the work. This examples does the same as the asynchronous usage example.

useApiClients\Client\Travis\Client;usefunctionApiClients\Foundation\resource_pretty_print;$client = Client::create('your travis key');resource_pretty_print($client->user());

Synchronous results stream

Synchronous results streams are returned as an array.

useApiClients\Client\Travis\Client;usefunctionApiClients\Foundation\resource_pretty_print;$client = Client::create('your travis key');foreach ($client->broadcasts()as$broadcast) {resource_pretty_print($broadcast);};

Examples

Theexamples directory is filled with all kinds of examples for this package.

License

The MIT License (MIT)

Copyright (c) 2017 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp