northern-lights / polr-client
Client for Polr API
Requires
- php: >=7.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ^5.5
- psr/http-message: ^1.0
- symfony/serializer: ^4.2
- zendframework/zend-config: ^3.2
Requires (Dev)
- jakub-onderka/php-console-highlighter: ^0.4.0
- jakub-onderka/php-parallel-lint: ^1.0
- phpstan/phpstan: ^0.9.2
- phpunit/php-invoker: ^1.1
- phpunit/phpunit: ^6.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.3
- symfony/var-dumper: ^3.4
This package is auto-updated.
Last update: 2025-04-23 03:37:22 UTC
README
Introduction
REST API client written in PHP for cydrobolt/polr
Provides simple interface for interaction with Polr instances
Usage
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]
Installation
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.
Industry standards and best practices
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
TODO
- Implement shorten_bulk [/api/v2/action/shorten_bulk]
- Add Unit tests
- Add detailed API documentation
Disclaimer
This project or it's authors are not affiliated with the Polr Project or any third party.
License
The MIT License (MIT). Please see License File for more information.