This is the Official Stackable API PHP library for getting data from stacks.
Install using Composer
$ composer install get-stackable/stackable-php
Or simple include src/Stackable.php
file to your project.
Make sure to create an account at http://www.stackable.space and setup your Stack and Containers.
To initialize
$stackable = new Stackable('YOUR-STACK-PUBLIC-KEY-HERE');
To list all containers
$result = $stackable->getContainers();
print_r($result);
To get single containers
$result = $stackable->getContainer('CONTAINER-ID-HERE');
print_r($result);
To get all items within single container
$result = $stackable->getContainerItems('CONTAINER-ID-HERE');
print_r($result);
To get all items within stack
$result = $stackable->getAllItems();
print_r($result);
To get single item
$result = $stackable->getItem('ITEM-ID-HERE');
print_r($result);
To create new item
- First initialize, using PRIVATE KEY, (MAKE SURE YOU KEEP THIS KEY SAFE! MOSTLY ON SERVER SIDE)
$stackable = new Stackable('YOUR-STACK-PRIVATE-KEY-HERE');
var dataToPost = [
name => 'John Doe',
age => 29
];
$result = $stackable->createItem('CONTAINER-ID-HERE', dataToPost);
print_r($result);
To update an item
var dataToPost = [
name => 'John Doe',
age => 29
];
$result = $stackable->updateItem('ITEM-ID-HERE', dataToPost);
print_r($result);
To play with this library: https://beta.tehplayground.com/D85vaCf8xDxKeb8S
- Write tests.
- Test create and update item methods