PHP Client for the CBS API
A PHP client for the CBS APIs exposed for the UW-Madison DoIT Techstore.
Getting Started
Requirements
- PHP >= 5.3
- PHP SOAP Extension
Installing with composer
You can use composer to include this client in your project. Add the following to your
composer.json
file:
{
"repositories": [
{
"type": "vcs",
"url": "git@git.doit.wisc.edu:adi-ia/cbs-techstore-client-php.git"
}
]
}
You can now include adi-ia/cbs-techstore-client-php to the require
section of your composer.json
file.
To use the client, your application must require the vendor/autoload.php
file that Composer creates.
Sending a request
<?php
use edu\wisc\services\cbs\api\Product;
use edu\wisc\services\cbs\client\ProductServiceSoapClient;
use Money\Money;
$client = new ProductServiceSoapClient('username', 'password');
$product = (new Product())
->setItemNumber('itemNumber')
->setName('name')
->setCost(Money::USD(999)); // $9.99
$success = $client->createProduct($product)->isSuccess();
Please review the PHPDocs for these classes for more information.
Mock client
A mock client edu\wisc\services\cbs\client\MockProductServiceClient
is provided, which always returns that a product
was successfully created. It can also be configured to always return that a product was not created by passing a
constructor argument. See the class's PHPDoc for details.
Releasing the Client
You must have write access to the upstream repository to cut a release. This guide assumes you have an upstream remote set up in your Git repository.
- Determine the version number you want to release. This project uses semantic versioning. In
most cases, this should be the version currently in
composer.json
. - Run
git pull upstream master
to ensure you are cutting a release from the latest changes. - Verify the version field in
composer.json
andsonar-runner.properties
is correct and matches your release. - Run
composer update
. - Commit/push any version number changes to
composer.json
andcomposer.lock
to the upstream master branch. (No PR required.) - Run
./vendor/bin/phing release -Drelease.version=x.x.x
where x.x.x is the version you want to release - Increment the version fields in
composer.json
andsonar-runner.properties
by one patch version. - Commit and push changes to the upstream master branch. (No PR required.)
A tag will be created in the upstream repository for the given version. It will be immediately available to composer users.
References
- CBS Homepage
- CBS assistance: cbs-support@lists.wisc.edu
- Techstore Project