PHP code example of myabakus / teamworkpm

1. Go to this page and download the library: Download myabakus/teamworkpm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

myabakus / teamworkpm example snippets




// START configuration
const API_KEY = 'horse48street';
const API_URL = 'https://yourcustomdomain.com'; // only have a custom domain:
    // Tpm::auth(API_URL, API_KEY);

    // if you do have a need use different format:
    // Tpm::auth(API_URL, API_KEY, API_FORMAT);

    // create a project
    $project_id = Tpm::project()->save([
        'name' => 'This is a test project',
        'description' => 'Bla, Bla, Bla',
    ]);

    // create one people and add to project
    $person_id = Tpm::people()->save([
        'first_name' => 'Test',
        'last_name' => 'User',
        'user_name' => 'test',
        'email_address' => '[email protected]',
        'password' => 'foo123',
        'project_id' => $project_id,
    ]);

    // create a milestone
    $milestone_id = Tpm::milestone()->save([
        'project_id' => $project_id,
        'responsible_party_ids' => $person_id,
        'title' => 'Test milestone',
        'description' => 'Bla, Bla, Bla',
        'deadline' => date('Ymd', strtotime('+10 day')),
    ]);

    // create a task list
    $task_list_id = Tpm::taskList()->save([
        'project_id' => $project_id,
        'milestone_id' => $milestone_id,
        'name' => 'My first task list',
        'description' => 'Bla, Bla',
    ]);

    // create a task
    $task_id = Tpm::task()->save([
        'task_list_id' => $task_list_id,
        'content' => 'Test Task',
        'notify' => false,
        'description' => 'Bla, Bla, Bla',
        'due_date' => date('Ymd', strtotime('+10 days')),
        'start_date' => date('Ymd'),
        'private' => false,
        'priority' => 'high',
        'estimated_minutes' => 1000,
        'responsible_party_id' => $person_id,
    ]);

    // add time to task
    $time_id = Tpm::time()->save([
        'task_id' => $task_id,
        'person_id' => $person_id,
        'description' => 'Test Time',
        'date' => date('Ymd'),
        'hours' => 5,
        'minutes' => 30,
        'time' => '08:30',
        'isbillable' => false,
    ]);

    echo 'Project Id: ' . $project_id . "\n";
    echo 'Person Id: ' . $person_id . "\n";
    echo 'Milestone Id: ' . $milestone_id . "\n";
    echo 'Task List Id: ' . $task_list_id . "\n";
    echo 'Task Id: ' . $task_id . "\n";
    echo 'Time id: ' . $time_id . "\n";
} catch (Exception $e) {
    print_r($e);
}