Helix :: Asana

A fluent PHP library for Asana's REST API

php stable unstable build score downloads license

Documentation: https://hfw.github.io/asana

composer require hfw/asana

For Laravel, see /src/Api/Laravel

Introduction

$api = new Api( ACCESS TOKEN );

The Api instance is the central access point for entities, and pools entities to avoid redundant network calls and prevent object duplication.

It's also used as a library-wide factory. Subclassing Api and overriding factory() lets you return whatever you want for any given endpoint.

You don't need to call new outside of instantiating the Api class. All library objects are injected with the Api instance and use factory() to give you what you want.

Example: You

$me = $api->getMe();
echo $me->getUrl();

Example: Workspaces

// if you're only in one workspace, then it's a safe default
$workspace = $api->getWorkspace();
// or you can set a default
$api->setWorkspace( GID );
$workspace = $api->getWorkspace();
// or you can get a specific workspace any time
$workspace = $api->getWorkspace( GID );

Example: Projects

// create a project
$project = $workspace->newProject()
->setName('Test Project')
->setNotes('A test project.')
->setOwner($me)
->create();
echo $project->getUrl();
// get a project
$project = $api->getProject( GID );

Example: Tasks

// create a task
$task = $project->newTask()
->setAssignee($me)
->setName('Test Task')
->setNotes('A test task.')
->create();
echo $task->getUrl();
// iterate your tasks
$taskList = $me->getTaskList();
foreach ($taskList as $task){
// ...
}

Class Diagram

Helix\Asana\Api
API access.
Definition: Api.php:24