Download the PHP package soulssoft/phraseanet-php-sdk without Composer
On this page you can find all versions of the php package soulssoft/phraseanet-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phraseanet-php-sdk
Phraseanet API PHP-SDK
The Phraseanet PHP SDK is an OO library to interact with Phraseanet API.
Install
The recommended way to install Phraseanet PHP SDK is through composer.
Basic Usage
Create the application
Here is the minimum to create the Phraseanet SDK Application ; please
note that client client-id
, url
and secret
a required. Please refer to
the online documentation
to get more more information about generating those.
Getting an oauth token
Once the application is created, a token is required to query the API. There are two ways :
Developer token
The developer token can be retrieved from Phraseanet developer application panel (My account > developer > applications).
OAuth2 authentication flow
Phraseanet SDK provides a convenient way to retrieve an oauth token. Use the OAuth2Connector for that :
- Redirect the end user to the Phraseanet authorization URL :
Note that extra parameters can be passed to the getAuthorizationUrl
method.
Please refer to the online documentation
about available parameters.
- Retrieve an access token in your application callback :
Once you have the token, you can use the EntityManager
.
Use the EntityManager
The EntityManager
is the entry point to retrieve Phraseanet entities.
Uploading files to Phraseanet
Files can be uploaded to Phraseanet using the uploader instance exposed via the Application
object:
$base_id
can be either a base_id
value or a PhraseanetSDK\Entity\DataboxCollection
entity.
Please note that you can force the behavior with the third argument and pass a Phraseanet record status (binary string) as fourth argument :
Behavior can be either :
- 0 to force record
- 1 to force quarantine
- null to let Phraseanet check (default behavior)
Configuration
Extended API Response format
The Phraseanet API (v1.4.1) can provide extended Response format for Record Object.
In this case all relations to Record object (permalink, sub-definitions, caption, status) are included in the response.
The result is that with this feature you need only one request to populate a whole Record object instead of five.
The time to hydrate record object is slightly higher but is ridiculously tiny compared to the time spent over HTTP protocol to fetch relations data.
Log
Request can be logged for monitor or debug purpose by setting a PSR Logger in the configuration. See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
See http://guzzle3.readthedocs.org/plugins/log-plugin.html for log plugin configuration
Cache
For performance, it is strongly recommended to use a cache system. This can be easily done using the following configuration.
See http://guzzle3.readthedocs.org/plugins/cache-plugin.html for cache plugin configuration.
Silex Provider
A Silex provider is bundled within this package.
Basic usage
Record / Play requests
Recorder
Recorder can be enabled per requests through service provider using the following code :
Requests can be store either in memcache
, memcached
or file
. To use file,
configuration should look like :
Player
To replay stored requests, use the player
Please note that, in order to play request without using cache (to warm it for
example), you must use the deny
cache re-validation strategy :
Monitor
SDK provides a tool to monitor Phraseanet :
License
Phraseanet SDK is released under the MIT license.
All versions of phraseanet-php-sdk with dependencies
doctrine/cache Version ~1.0
doctrine/collections Version ~1.0
guzzle/guzzle Version ~3.0