ciromattia / laravel-teamwork
PHP wrapper for the Teamwork project management API
Installs: 586
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 47
pkg:composer/ciromattia/laravel-teamwork
Requires
- php: >=7.1.0
- guzzlehttp/guzzle: ~6.3
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0
Suggests
- illuminate/support: Required for Laravel support
README
This package aims to implement the Teamwork API in a Service Provider for Laravel 5.
Installation
Add the package through composer:
composer require "ciromattia/laravel-teamwork:~1.3"
Laravel Setup
The Service Provider is auto-discoverable by Laravel 5.5+.
If you're using Laravel 5.4 or earlier, you have to manually add the following to your config/app.php file.
'providers' => [ ... 'Ciromattia\Teamwork\TeamworkServiceProvider', ],
and then add the facade to your aliases array
'aliases' => [ ... 'Teamwork' => 'Ciromattia\Teamwork\Facades\Teamwork', ],
Configuration
Add a teamwork array to your config/services.php file
... 'teamwork' => [ 'key' => 'YourSecretKey', 'url' => 'YourTeamworkUrl' ],
Use
There are two ways to use this stuff: the first is by the Teamwork Facade, like this
Teamwork::people()->all();
If you want to use dependency injection to make your application easy to test, the Service Provider binds Ciromattia\Teamwork\Factory. Here is an example of how to use it with dependency injection
Route::get('/test', function(Ciromattia\Teamwork\Factory $teamwork) { $activity = $teamwork->activity()->latest(); });
Methods
The methods available mimic the Teamwork entities in lowercase and query the namesake API, so you can retrieve e.g. a single project with:
Teamwork::project($project_id)->find();
Common methods available to all the entities are:
all()- returns all the query results (i.e. all the entity objects).find($id)- returns a single object with the specified ID.create($data)- creates a single object with$dataparameters.update($data)- updates a single object with$dataparameters.delete($id)- deletes a single object with the specified ID.
The implemented entities at the moment are:
The following special entities don't have the common methods specified above:
Configuration Without Laravel
If you are not using Laravel you can instantiate the class like this
require "vendor/autoload.php"; use GuzzleHttp\Client as Guzzle; use Ciromattia\Teamwork\Client; use Ciromattia\Teamwork\Factory as Teamwork; $client = new Client(new Guzzle, 'YourSecretKey', 'YourTeamworkUrl'); $teamwork = new Teamwork($client);
You are ready to go now!
Examples
Not all of the Teamwork API is supported yet but there is still a lot you can do! Below are some examples of how you can access Projects, Companies, and more. To work with a specific Object pass in the ID to perform actions on it. Data can be passed through for creating and editing.
To see more examples visit the docs
// create a project $teamwork->project()->create([ "name" => "My New Amazing Project", "description" => "This is a project that I will dedicate my whole life too", "companyId" => "999" ]); // get the latest activity on a project $teamwork->project($projectID)->activity();
Roadmap
2.0 Release
- Add support for paging
- Add Support For
Comments - Add Support For
Permissions - Add Support For
Categories - Add Support For
People Status - Add Support For
Files - Add Support For
Notebooks
Credits
This library is an evolution of the now abandoned Teamwork 5 PM API Bridge by Ross Edman.