flatplanapp / flatplansdk
PHP SDK to access Flat Plan.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- phpunit/phpunit: ^9.5.10
README
This repository contains the open source PHP SDK that allows you to access the FlatPlan Platform from your PHP CMS.
Installation
The FlatPlan PHP SDK can be installed with Composer. Run this command:
composer require flatplanapp/flatplansdk
Please be aware, that whilst in beta there is always the possibility you will come across occasional bugs. Please report any issues you come across to the team using the issue tracker on Bitbucket
API Credentials
In order to access the platform via this SDK, you will need an Access Token and Application ID. These can be obtained by emailing accounts@flatplan.app. These credentials will need to be kept safe and passed to the FlatPlan constructor as in the example below. If at any point you believe your access token has been compromised, you should email accounts@flatplan.app to receive details on how to generate a new token.
Usage
Note: This version of the FlatPlan SDK for PHP requires PHP v8.0 or greater.
Simple GET example of a user's articles.
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
$fp = new FlatPlan\FlatPlan(
$accessToken,
$appId
);
// Get a list of articles associated with the current application
// By default, this will return the 10 most recent articles sent to FlatPlan
$articles = $fp->getArticles();
foreach ($articles as $article):
echo '<strong>Article ID:</strong> ' . $article->id . '<br>' . PHP_EOL;
echo '<strong>Article Title:</strong> ' . $article->title . '<br>' . PHP_EOL;
echo '<strong>Article Status:</strong> ' . $article->status . '<br><br>' . PHP_EOL;
endforeach;
Complete documentation, installation instructions, and examples are available here.
Tests
- Composer is a prerequisite for running the tests. Install composer globally, then run
composer install
to install required files. - Create a test app on FlatPlan, then create
tests/FlatPlanTestCredentials.php
fromtests/FlatPlanTestCredentials.php.dist
and edit it to add your credentials. - The tests can be executed by running this command from the root directory:
$ ./vendor/bin/phpunit
By default the tests will send live HTTP requests to the FlatPlan API.