Skip to content

justinrainbow/basecamp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basecamp API Wrapper for php 5.3+

This is a php library to access the Basecamp api. Collection classes provide methods to query the api and wrap each result item in an entity object. Entity objects come with methods such as update() and delete() to persist themselfes via the api. Functionality is provided to attach and detach observers to collections and entities – this is useful for logging or to print current activity to the terminal.

Supported Features

  • Person: startMe(), startById(), startAllByProjectId(), startAll() etc
  • Project: startById(), startAll(), copy(), replicate() etc
  • Milestone: startAllByProjectId(), create(), update(), delete(), complete(), uncomplete() etc
  • Todolist: startById(), startAllByProjectId(), startAllByResponsibiltyParty(), create(), update(), delete() etc
  • Todoitems: startAllByTodoListId(), startById(), create(), update(), delete(), complete(), uncomplete() etc
  • Comments: startAllByResourceId(), startById()

Requirements

  • php 5.3+ (uses namespaces)
  • Recent version of zend framework (tested with 1.10) > uses Zend_Http_Client & Zend_Log (optional)

Getting Started

Please find plenty of working examples in the basecamp/example/basecamp directory. Here’s the basics:

First Steps

  1. create a dummy project in your basecamp account
  2. adjust basecamp/example/basecamp/_config.php with your own settings
  3. make files executable in basecamp/example/basecamp/(milestone|person|project|todoitem|todolist)/*
  4. make writeable basecamp/example/_logs
  5. run examples

Setup

$config = array(
	'baseUri' => 'https://xxx.basecamphq.com',
	'username' => 'xxx',
	'password' => 'xxx'
);

require_once 'Sirprize/Basecamp.php';
$basecamp = new \Sirprize\Basecamp($config);

Fetch all projects

$projects = $basecamp->getProjectsInstance()->startAll();

foreach($projects as $project)
{
	print $project->getName()."\n";
}

Copy a project

/*
 *
 * populate the target-project with the milestones,
 * todo-lists and todo-items from the source-project
 *
 */

require_once 'Sirprize/Basecamp/Id.php';
$sourceProjectId = new \Sirprize\Basecamp\Id('xxx');
$targetProjectId = new \Sirprize\Basecamp\Id('yyy');

$projects = $basecamp->getProjectsInstance();
$sourceProject = $projects->startById($sourceProjectId);
$sourceProject->copy($targetProjectId);

Replicate a project (push deadlines to a new date)

/*
 *
 * populate the target-project with the milestones,
 * todo-lists and todo-items from the source-project.
 * the last milestone deadline is pushed to 2010-12-30 and
 * all other deadlines will be calculated relative to it
 *
 */

require_once 'Sirprize/Basecamp/Id.php';
$sourceProjectId = new \Sirprize\Basecamp\Id('xxx');
$targetProjectId = new \Sirprize\Basecamp\Id('yyy');

$projects = $basecamp->getProjectsInstance();
$sourceProject = $projects->startById($sourceProjectId);

require_once 'Sirprize/Basecamp/Date.php';
$referenceDate = new \Sirprize\Basecamp\Date('2010-12-30');

require_once 'Sirprize/Basecamp/Schema/Export.php';
$referenceMilestone = \Sirprize\Basecamp\Schema\Export::REFERENCE_EXTREMITY_LAST;
$sourceProject->replicate($targetProjectId, $referenceDate, $referenceMilestone);

Create a new milestone

$milestones = $basecamp->getMilestonesInstance();
$milestone = $milestones->getMilestoneInstance();

require_once 'Sirprize/Basecamp/Date.php';
$deadline = new \Sirprize\Basecamp\Date('2010-03-01');

require_once 'Sirprize/Basecamp/Id.php';
$projectId = new \Sirprize\Basecamp\Id('xxx');
$userId = new \Sirprize\Basecamp\Id('xxx');

$milestone
	->setProjectId($projectId)
	->setResponsiblePartyId($userId)
	->setDeadline($deadline)
	->setTitle('Milestoners Everywhere')
	->setWantsNotification(true)
	->create()
;

Todo

  • Account
  • Companies
  • Categories
  • Messages
  • Comments (create(), update(), delete())
  • Time tracking

About

Basecamp API Wrapper for PHP 5.3+

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%