1. Go to this page and download the library: Download sphere/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sphere / php-sdk example snippets
ommercetools\Core\Builder\Request\RequestBuilder;
use Commercetools\Core\Client;
use Commercetools\Core\Config;
use Commercetools\Core\Model\Common\Context;
$config = [
'client_id' => 'my client id',
'client_secret' => 'my client secret',
'project' => 'my project id'
];
$context = Context::of()->setLanguages(['en'])->setLocale('en_US')->setGraceful(true);
$config = Config::fromArray($config)->setContext($context);
/**
* create a search request and a client,
* execute the request and get the PHP Object
* (the client can and should be re-used)
*/
$search = RequestBuilder::of()->productProjections()->search()
->addParam('text.en', 'red');
$client = Client::ofConfig($config);
$products = $client->execute($search)->toObject();
/**
* show result (would be a view layer in real world)
*/
header('Content-Type: text/html; charset=utf-8');
foreach ($products as $product) {
echo $product->getName()->en . '<br/>';
}
bash
# Install Composer if not installed yet
curl -sS https://getcomposer.org/installer | php
bash
composer
sh
xcode-select --install
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php56
brew install php56-intl
brew install php56-xdebug
brew install ant
# you probably also need to fix a (=any) timezone in your php.ini:
echo "date.timezone='Europe/Berlin'" >> /usr/local/etc/php/5.6/conf.d/60-user.ini
# initialize the dependencies:
php composer.phar update