Download the PHP package adeelnawaz/polr-api-bundle without Composer
On this page you can find all versions of the php package adeelnawaz/polr-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adeelnawaz/polr-api-bundle
More information about adeelnawaz/polr-api-bundle
Files in adeelnawaz/polr-api-bundle
Package polr-api-bundle
Short Description Integration of Polr API Client into Symfony
License MIT
Informations about the package polr-api-bundle
Polr API Bundle
(Note: This version is not compatible with Symfony 3. Please use version 0.1.1 for apps running on Symfony 3)
This bundle provides Polr API Client integration in Symfony (4|5). This bundle is simply a wrapper over PHP package
adeelnawaz/polr-api-client
. The bundle exposes a service PolrApiService
that can be utilized to call API methods of
the PolrApi
class from API Client package.
Installation
Step 1: Configuration
Create a configuration file in your config
directory named polr_api.yml
containing the following configuration:
In .env[.*]
file, add the following environment variables
Note: The POLR_API_QUOTA
value makes sure that your application separates the API calls with enough delay that you
don't exceed your calls/minute quota. If you specify a smaller value than your API key's actual quota then you will get
an error from your Polr API.
Step 2: Install via Composer
In your console, navigate to your Symfony project directory and execute the following command to download the latest stable version of this package:
Step 3: Enable the Bundle
For apps with Symfony Flex, this step is not needed. Otherwise add the bundle to the list of registered bundles in
config/bundles.php
:
All done!
Usage
In order to consume the API, use the service PolrApiService
. Create DTO object(s)
(Adeelnawaz\PolrApiClient\DTO\Link
, etc) for the method you
intend to use and call the method. This will result in calling the respective REST API
endpoint and returning the relative Adeelnawaz\PolrApiClient\DTO\Response
object.
(See Docblocks of the PolrApiService
methods for further information on input/output DTOs)
In case of a failed API call, the PolrApiService
methods throw Adeelnawaz\PolrApiClient\Exception\ApiResponseException
. The
exception has getters for code
, message
, and a machine readable short string
error_code
returned by the Polr REST API.
Example controller:
See also
Polr API Client Documentation.