Class Config
Client configuration object
- Commercetools\Core\Config implements Commercetools\Core\Model\Common\ContextAwareInterface uses Commercetools\Core\Model\Common\ContextTrait
Namespace: Commercetools\Core
Description:
Located at Core/Config.php
Description:
Often configuration like credentials is stored in YAML or INI files. To setup the configuration object this can be done by the fromArray method.
Configuration file:
[commercetools] client_id = '<client-id>' client_secret = '<client-secret>' project = '<project>'
Config instantiation:
$iniConfig = parse_ini_file('<config-file>.ini', true); $config = Config::fromArray($iniConfig['commercetools']);
Exceptions
The client by default suppresses exceptions when a response had been returned by the API and the result can be handled afterwards by checking the isError method of the response. For interacting with Exceptions they can be enabled with the throwExceptions flag.
$config->setThrowExceptions(true); $client = new Client($config); try { $response = $client->execute($request); } catch (\Commercetools\Core\Error\ApiException $e) { // handle Exception }
Located at Core/Config.php
Methods summary
Methods inherited from Commercetools\Core\Model\Common\ContextAwareInterface
getContext()
,
getContextCallback()
,
setContext()
,
setContextIfNull()
Methods used from Commercetools\Core\Model\Common\ContextTrait
getContext()
,
getContextCallback()
,
setContext()
,
setContextIfNull()
Constants summary
string |
OAUTH_URL
|
#
'oauth_url'
|
string |
CLIENT_ID
|
#
'client_id'
|
string |
CLIENT_SECRET
|
#
'client_secret'
|
string |
SCOPE
|
#
'scope'
|
string |
PROJECT
|
#
'project'
|
string |
API_URL
|
#
'api_url'
|
string |
USER_NAME
|
#
'username'
|
string |
PASSWORD
|
#
'password'
|
string |
REFRESH_TOKEN
|
#
'refresh_token'
|
string |
BEARER_TOKEN
|
#
'bearer_token'
|
string |
ANONYMOUS_ID
|
#
'anonymous_id'
|
string |
GRANT_TYPE
|
#
'grant_type'
|
string |
GRANT_TYPE_CLIENT
|
#
'client_credentials'
|
string |
GRANT_TYPE_PASSWORD
|
#
'password'
|
string |
GRANT_TYPE_REFRESH
|
#
'refresh_token'
|
string |
GRANT_TYPE_ANONYMOUS
|
#
'anonymous_token'
|
string |
GRANT_TYPE_BEARER_TOKEN
|
#
'bearer_token'
|