A fluent PHP library for Asana's REST API
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
$workspace = $api->getWorkspace();
$api->setWorkspace( GID );
$workspace = $api->getWorkspace();
$workspace = $api->getWorkspace( GID );
Example: Projects
$project = $workspace->newProject()
->setName('Test Project')
->setNotes('A test project.')
->setOwner($me)
->create();
echo $project->getUrl();
$project = $api->getProject( GID );
Example: Tasks
$task = $project->newTask()
->setAssignee($me)
->setName('Test Task')
->setNotes('A test task.')
->create();
echo $task->getUrl();
$taskList = $me->getTaskList();
foreach ($taskList as $task){
}
Class Diagram