Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A client written in PHP
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PHP Tent Client

Tent Client API for PHP is a distributed protocol for social networking. There are tent servers and tent applications. Users host their data on tent servers. Tent applications can modify this data. To implement a tent application you need a client. This library provides a client written in PHP.

The client has to act as an application to be able to access user details on any tent server. to work applications are always required to maintain some level of state about Tent Servers Url and their OAuth Client Ids and Mac Keys.


  • Support for the Application API
  • Automatic registration of Applications on any tent-server
  • Persistence of application and user authorizations (MAC Auth)

State & Persistence

This application state is hidden behind a persistence interface TentPHP\Persistence\ApplicationState. We are shipping a Doctrine DBAL based implementation.

Other clients (PHP + other languages) put the burdon of persistence on you, returning all the data that is stateful from their methods. With the ApplicationState interface you can implement this yourself, or use our Doctrine backend. In any case this simplifies the usage of the client considerably.


Use Composer to install TentPHP and all its dependencies:

    "require": {
        "beberlei/tent-php": "*",
        "doctrine/dbal": "*"

API (With Doctrine DBAL)

Setup & Configuration

use TentPHP\Application;
use TentPHP\Client;
use TentPHP\PhpSessionState;
use TentPHP\DBAL\DoctrineUserStorage;
use Doctrine\DBAL\DriverManager;
use Guzzle\Http\Client as HttpClient;

$application = new Application(array(
  "name" => "FooApp",
  "description" => "Does amazing foos with your data",
  "url" => "http =>//",
  "icon" => "http =>//",
  "redirect_uris" => array(
    "https =>//"
  "scopes" => array(
    "write_profile" => "Uses an app profile section to describe foos",
    "read_followings" => "Calculates foos based on your followings"

$conn = DriverManager::getConnection(array(
    'driver'   => 'pdo_mysql',
    'host'     => 'localhost',
    'dbname'   => 'tentclient',
    'username' => 'user',
    'password' => 'pw',
$encryptionKey = "abcdef12345";

$userStorage = new DoctrineUserStorage($conn);
$state       = new PhpSessionState();
$client      = new Client($application, $httpClient, $userStorage, $state);

Request Login URL for User

$loginUrl = $client->getLoginUrl('');
header("Location: " . $loginUrl);

Authorize after OAuth grant

$client->authorize($_GET['state'], $_GET['code']);

Get UserClient

$user = $client->getUserClient('');
Something went wrong with that request. Please try again.