Download the PHP package bynder/bynder-php-sdk without Composer
On this page you can find all versions of the php package bynder/bynder-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bynder/bynder-php-sdk
More information about bynder/bynder-php-sdk
Files in bynder/bynder-php-sdk
Package bynder-php-sdk
Short Description Bynder PHP Library
License MIT
Homepage https://www.bynder.com
Informations about the package bynder-php-sdk
Bynder PHP SDK
The main goal of this SDK is to speed up the integration of Bynder customers who use PHP. Making it easier to connect to the Bynder API (https://bynder.docs.apiary.io) and executing requests on it.
Requirements and dependencies
The PHP SDK requires the following in order to fully work:
PHP >= 5.6
, older versions of PHP not recommendedcurl
, although you can use your own non-cURL client if you prefer
Composer should handle all the dependencies automatically.
Composer package
The Bynder PHP SDK is published as a composer package in packagist and can be found here:
Installation
This SDK depends on a few libraries in order to work, installing it with Composer should take care of everything automatically.
To install the SDK with Composer. Run the following command at the root of the project:
To use the SDK, we use Composer's autoload in order to include all the files automatically:
How to use it
This is a simple example on how to retrieve data from the Bynder asset bank. For a more detailed example of implementation refer to the sample code.
Before executing any request to the Bynder API we need to instantiate the BynderApi class, the following example shows how to use the BynderApiFactory to construct a BynderApi instance:
The SDK allows the usage of the Guzzle request options. This can be done by passing the last argument when initiating the Configuration object:
After getting the BynderClient service configured successfully we need to get an instance of the AssetBankManager in order to do any of the API calls relative to the Bynder Asset Bank module:
And with this, we can start our request to the API, listed in the Methods Available section following. Short example of getting all the Media Items:
This call will return a list with all the Media Items available in the Bynder environment. Note that some of the calls accept a query array in order to filter the results via the API call params (see Bynder API Docs) for more details. For instance, if we only wanted to retrieve 2 images here is what the call would look like:
All the calls are Asynchronous, which means they will return a Promise object, making it a bit more flexible in order to adjust to any kind of application. Again, for a more thorough example there is a sample application use case in this repo.
Methods Available
These are the methods currently available on the Bynder PHP SDK, refer to the Bynder API Docs) for more specific details on the calls.
BynderClient:
Handles the process of generating and setting the access token required for the requests to the API. Also has calls related to users.
AssetBankManager:
All the Asset Bank related calls, provides information and access to Media management.
Tests
Using Docker
Build the Docker image and tag it:
Run the tests:
Running it locally
Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:
Or to run an individual test file:
Sample Files Functionality Testing
Scripts within sample
contain code to execute corresponding functionalities. The purpose is to demonstrate how methods
are called and provide a convenient method to execute functions.
Within sample
create a file called sample_config.php
. This file will be referenced from sample files.
Make sure all values are populated correctly before running sample files.
Example sample_config.php
file content:
Within each sample file, OAuth credentials are read in from sample_config.php
.
Scripts will output authorization url to navigate to retrieve access code (will not open browser automatically, user must click link).
Access code is then provided to terminal prompt to retrieve an access token for API calls afterward.
Command Line Instructions
Make sure both composer
and php
are installed locally. From root directory run composer install
to install packages
form composer.json
. Navigate to sample
directory.
Brands Sample
Methods Used:
- getBrands()
Collections Sample
Methods Used:
- getCollections($query)
- getCollectionAssets($collectionId)
Media Sample
Methods Used:
- getDerivatives()
- getMediaList($query)
- getMediaInfo($mediaId)
- getMediaDownloadLocation($mediaId)
- getMediaDownloadLocationByVersion($mediaId, $version)
- getMediaDownloadLocationForAssetItem($mediaId, $itemId)
- modifyMedia($mediaId, $data)
- getMediaInfo($mediaId)
- deleteMedia($mediaId)
Metaproperties Sample
Methods Used:
- getMetaproperties()
- getMetaproperty($metapropertyId)
- getMetapropertyDependencies($metapropertyId)
- getMetapropertyOptions($query)
- getMetapropetryGlobalOptionDependencies()
- getMetapropertyOptionDependencies($metapropertyId)
- getMetapropertySpecificOptionDependencies($metapropertyId, $metapropertyOptionId, $array)
Smart Filters Sample
Methods Used:
- getSmartfilters()
Tags Sample
Methods Used:
- getTags()
Uploads Sample
Methods Used:
- uploadFileAsync($data)
- getBrands()
Usage Sample
Methods Used:
- createUsage($data)
- getUsage($data)
- deleteUsage($data)
Docker Instructions
Sample files can be executed within Docker container. Makefile contains corresponding commands to run/build Docker container.
Dockerfile.dev
file is used for container.
Makefile commands are executed from root directory. Run with sudo if permission is needed.
If needed, pull latest composer
Docker image docker pull composer:latest
Makefile commands:
Build and start up Docker container for PHP SDK using Docker Compose
Stop running Docker container for PHP SDK:
Run sample file within Docker container (BrandsSample.php is replaced with target sample file):