REST API client written in PHP for cydrobolt/polr
Provides simple interface for interaction with Polr instances
Very minimal example, using default configuration
<?php
namespace NorthernLights\Client\Polr\Example;
use NorthernLights\Client\Polr\ApiClient;
use NorthernLights\Client\Polr\Config\Config;
use NorthernLights\Client\Polr\Response\ShortenResponseInterface;
/**
* Initialize API client and pass $config to it (DI)
* @var ApiClient $api
*/
$api = new ApiClient();
/**
* Shorten the long URL.
* @var ShortenResponseInterface $response
*/
$response = $api->shorten('https://www.polrproject.org');
// Check if API request was successful. Remains true as long as HTTP status code equals 200 OK
if (!$response->wasSuccessful()) {
echo 'There was an error querying the api' . PHP_EOL;
exit(1);
}
echo 'Short URL is ' . $response->getShortUrl() . PHP_EOL;
For more detailed examples and configuration, please take a look in examples. All use scenarios are covered.
- configuration
- lookup [/api/v2/action/lookup]
- shorten [/api/v2/action/shorten]
- shorten_bulk [/api/v2/action/shorten_bulk]
- data [/api/v2/data/link]
The recommended way to install is via Composer:
composer require northern-lights/polr-client
Alternatively, you can download latest stable version from releases.
Please note that this library doesn't ship with autoloader, but relies on Composer internal autoloader.
Library strives to comply with latest standards and best practices in the industry therefore we included
PSR-2 coding standard Compliance check & fix
We want the code to be as good as it is possible
$ composer check-style
$ composer fix-style
Note: Second command will actually modify files
Code syntax check (lint)
Very basic check which saves us the trouble
$ composer php-lint
Static Code Analysis
So we catch bugs early.
$ composer phpsam
Unit testing
So we make sure that all moving parts are running smoothly
$ composer test
- Implement shorten_bulk [/api/v2/action/shorten_bulk]
- Add Unit tests
- Add detailed API documentation
This project or it's authors are not affiliated with the Polr Project or any third party.
The MIT License (MIT). Please see License File for more information.