Composable Commerce PHP SDKPHP SDK
  • Namespace
  • Class
  • Tree

Namespaces

  • Commercetools
    • Commons
      • Helper
    • Core
      • Builder
        • Request
        • Update
      • Cache
      • Client
        • Adapter
        • OAuth
      • Error
      • Helper
        • Annotate
        • State
          • Renderer
        • Subscriber
          • Log
      • Model
        • ApiClient
        • Cart
        • CartDiscount
        • Category
        • Channel
        • Common
        • Customer
        • CustomerGroup
        • CustomField
        • CustomObject
        • DiscountCode
        • Extension
        • Inventory
        • Message
        • Order
        • OrderEdit
        • Payment
        • Product
          • Search
        • ProductDiscount
        • ProductSelection
        • ProductType
        • Project
        • Review
        • ShippingMethod
        • ShoppingList
        • State
        • Store
        • Subscription
        • TaxCategory
        • Type
        • Zone
      • Request
        • ApiClients
        • CartDiscounts
          • Command
        • Carts
          • Command
        • Categories
          • Command
        • Channels
          • Command
        • CustomerGroups
          • Command
        • Customers
          • Command
        • CustomField
          • Command
        • CustomObjects
        • DiscountCodes
          • Command
        • Extensions
          • Command
        • GraphQL
        • InStores
        • Inventory
          • Command
        • Me
          • Command
        • Messages
        • OrderEdits
          • Command
          • StagedOrder
            • Command
        • Orders
          • Command
        • Payments
          • Command
        • ProductDiscounts
          • Command
        • Products
          • Command
        • ProductSelections
          • Command
        • ProductTypes
          • Command
        • Project
          • Command
        • Query
        • Reviews
          • Command
        • ShippingMethods
          • Command
        • ShoppingLists
          • Command
        • States
          • Command
        • Stores
          • Command
        • Subscriptions
          • Command
        • TaxCategories
          • Command
        • Types
          • Command
        • Zones
          • Command
      • Response

Classes

  • AbstractHttpClient
  • Client
  • Config

Class Config

Client configuration object

Commercetools\Core\Config implements Commercetools\Core\Model\Common\ContextAwareInterface uses Commercetools\Core\Model\Common\ContextTrait
Namespace: Commercetools\Core
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

public
# __construct( )
public static Commercetools\Core\Config
# fromArray( array $configValues )

Parameters

$configValues

Returns

Commercetools\Core\Config
public string
# getClientSecret( )

Returns

string
public Commercetools\Core\Config
# setClientSecret( string $clientSecret )

Parameters

$clientSecret

Returns

Commercetools\Core\Config
$this
public string
# getClientId( )

Returns

string
public Commercetools\Core\Config
# setClientId( string $clientId )

Parameters

$clientId

Returns

Commercetools\Core\Config
$this
public string
# getProject( )

Returns

string
public Commercetools\Core\Config
# setProject( string $project )

Parameters

$project

Returns

Commercetools\Core\Config
$this
public string
# getScope( )

Returns

string
public Commercetools\Core\Config
# setScope( string $scope )

Parameters

$scope

Returns

Commercetools\Core\Config
$this
public string
# getOauthUrl( string|null $grantType = null )

Parameters

$grantType

Returns

string
public Commercetools\Core\Config
# setOauthUrl( string $oauthUrl )

Parameters

$oauthUrl

Returns

Commercetools\Core\Config
$this
public string
# getApiUrl( )

Returns

string
public Commercetools\Core\Config
# setApiUrl( string $apiUrl )

Parameters

$apiUrl

Returns

Commercetools\Core\Config
$this
public boolean
# check( )

Returns

boolean
public integer
# getBatchPoolSize( )

Deprecated

use getClientOptions()['concurrency'] instead

Returns

integer
public Commercetools\Core\Config
# setBatchPoolSize( integer $batchPoolSize )

Deprecated

use setClientOptions(['concurrency' => 5]) instead

Parameters

$batchPoolSize

Returns

Commercetools\Core\Config
$this
public string
# getAdapter( )

Returns

string
public Commercetools\Core\Config
# setAdapter( string $adapter )

Parameters

$adapter

Returns

Commercetools\Core\Config
$this
public boolean
# getThrowExceptions( )

Returns

boolean
public Commercetools\Core\Config
# setThrowExceptions( boolean $throwExceptions )

Parameters

$throwExceptions

Returns

Commercetools\Core\Config
$this
public string
# getAcceptEncoding( )

Returns

string
public Commercetools\Core\Config
# setAcceptEncoding( string $acceptEncoding )

Parameters

$acceptEncoding

Returns

Commercetools\Core\Config
$this
public static Commercetools\Core\Config
# of( )

Returns

Commercetools\Core\Config
public string
# getGrantType( )

Returns

string
public Commercetools\Core\Config
# setGrantType( string $grantType )

Parameters

$grantType

Returns

Commercetools\Core\Config
$this
public string
# getUsername( )

Returns

string
public Commercetools\Core\Config
# setUsername( string $username )

Parameters

$username

Returns

Commercetools\Core\Config
$this
public string
# getPassword( )

Returns

string
public Commercetools\Core\Config
# setPassword( string $password )

Parameters

$password

Returns

Commercetools\Core\Config
$this
public string
# getRefreshToken( )

Returns

string
public Commercetools\Core\Config
# setRefreshToken( string $refreshToken )

Parameters

$refreshToken

Returns

Commercetools\Core\Config
$this
public string
# getAnonymousId( )

Returns

string
public Commercetools\Core\Config
# setAnonymousId( string $anonymousId )

Parameters

$anonymousId

Returns

Commercetools\Core\Config
$this
public string
# getCacheDir( )

Returns

string
public Commercetools\Core\Config
# setCacheDir( string $cacheDir )

Parameters

$cacheDir

Returns

Commercetools\Core\Config
$this
public string
# getLogLevel( )

Returns

string
public Commercetools\Core\Config
# setLogLevel( string $logLevel )

Parameters

$logLevel

Returns

Commercetools\Core\Config
$this
public mixed
# getMessageFormatter( )

Returns

mixed
public Commercetools\Core\Config
# setMessageFormatter( mixed $messageFormatter )

Parameters

$messageFormatter

Returns

Commercetools\Core\Config
$this
public Commercetools\Core\Helper\CorrelationIdProvider|null
# getCorrelationIdProvider( )

Returns

Commercetools\Core\Helper\CorrelationIdProvider|null
public Commercetools\Core\Config
# setCorrelationIdProvider( Commercetools\Core\Helper\CorrelationIdProvider $correlationIdProvider )

Parameters

$correlationIdProvider

Returns

Commercetools\Core\Config
public boolean
# isEnableCorrelationId( )

Returns

boolean
public Commercetools\Core\Config
# setEnableCorrelationId( boolean $enableCorrelationId )

Parameters

$enableCorrelationId

Returns

Commercetools\Core\Config
public array
# getClientOptions( )

Returns

array
public Commercetools\Core\Config
# setClientOptions( array $clientOptions )

Parameters

$clientOptions

Returns

Commercetools\Core\Config
public array
# getOAuthClientOptions( )

Returns

array
public Commercetools\Core\Config
# setOAuthClientOptions( array $clientOptions )

Parameters

$clientOptions

Returns

Commercetools\Core\Config
public string
# getBearerToken( )

Returns

string
public Commercetools\Core\Config
# setBearerToken( string $bearerToken )

Parameters

$bearerToken

Returns

Commercetools\Core\Config
public
# getClientCredentials( )

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'
PHP SDK API documentation generated by ApiGen