-
Notifications
You must be signed in to change notification settings - Fork 179
Advanced Configuration
The Dropbox service class provides an easy interface for working with all the components of the SDK.
To configure the Dropbox
service class, an instance of DropboxApp needs to be passed as the first parameter.
The DropboxApp class needs to be configured with the client_id and client_secret obtained from the Dropbox Developer App Dashboard, by creating an Application.
use Kunnu\Dropbox\DropboxApp;
$app = new DropboxApp("client_id", "client_secret");
If you already have an access token, you can pass it to the constructor above as the third argument.
$app = new DropboxApp("client_id", "client_secret", 'access_token');
Once the DropboxApp has been configured, you can pass it as the first argument to the Dropbox service class:
use Kunnu\Dropbox\Dropbox;
$dropbox = new Dropbox($app);
You can further configure the Dropbox service class, by passing a configuration array as the second argument. Here are the available configuration options (with their defaults):
$config = [
'http_client_handler' => null,
'random_string_generator' => null,
'persistent_data_store' => null
];
$dropbox = new Dropbox($app, $config);
Allows you to overwrite the default HTTP Client Handler, which is used to make HTTP requests to the API.
The SDK will use Guzzle's implementation (DropboxGuzzleHttpClient
) as the default HTTP Client.
You can also write your own HTTP Client, by coding it to the DropboxHttpClientInterface
and passing it through the configuration array as:
$httpClient = new MyHttpClientHandler();
$config = [
'http_client_handler' => $httpClient,
];
Allows you to overwrite the default cryptographically secure pseudo-random string generator.
By default, the SDK will attempt to detect a suitable cryptographically secure random string generator.
You can explicitly set the random_string_generator
to either of the following methods: mcrypt
or openssl
.
You can also write your own Cryptographically Secure Random String Generator, by implementing RandomStringGeneratorInterface
and passing it through the configuration array as:
$randomStringGenerator = new MySecureRandomStringGenerator();
$config = [
'random_string_generator' => $randomStringGenerator,
];
Allows you to overwrite the default persistent data store.
By default, the SDK will try to use the native PHP session (SessionPersistentDataStore
) for the persistent data store.
You can also write your own persistent data store, by implementing PersistentDataStoreInterface
and passing it through the configuration array as:
$persistentDataStore = new MyPersistentDataStore();
$config = [
'persistent_data_store' => $persistentDataStore,
];