spatie/laravel-harvest-sdk
Laravel-friendly SDK for the Harvest.com API. Configure account ID, access token, and user agent, then resolve the Harvest client from the container or facade to call API endpoints. Not a complete implementation; PRs welcome.
Note: this is not a full implementation for the Harvest API, but we welcome PR's if you need anything that is still missing.
A Laravel-friendly SDK to interact with the Harvest API
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
You can install the package via composer:
composer require spatie/laravel-harvest-sdk
You can publish the config file with:
php artisan vendor:publish --tag="laravel-harvest-sdk-config"
Add your Harvest credentials to your .env file:
HARVEST_ACCOUNT_ID=your-account-id
HARVEST_ACCESS_TOKEN=your-access-token
HARVEST_USER_AGENT='name (name@email.com)'
To start interacting with the Harvest API, you can resolve the Harvest instance from the container or use the facade:
use Spatie\Harvest\Harvest;
$harvest = app(Harvest::class);
// or use the facade
use Spatie\Harvest\Facades\Harvest;
use Spatie\Harvest\Data\UserData;
use Spatie\Harvest\Facades\Harvest;
$user = Harvest::users()->me()->dto();
// Returns: UserData
use Spatie\Harvest\Data\UserData;
use Spatie\Harvest\Facades\Harvest;
$users = Harvest::users()->all()->dto();
// Returns: array<UserData>
use Spatie\Harvest\Data\ProjectData;
use Spatie\Harvest\Facades\Harvest;
$projects = Harvest::projects()->all()->dto();
// Returns: array<ProjectData>
Time entries are paginated. You must provide a from date, and optionally a to date and userId.
use Spatie\Harvest\Data\TimeEntryData;
use Spatie\Harvest\Facades\Harvest;
$paginator = Harvest::timeEntries()->all(from: '2024-01-01', to: '2024-01-31');
foreach ($paginator as $timeEntries) {
// Each page returns: array<TimeEntryData>
}
// Or collect all pages
$allTimeEntries = $paginator->collect();
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
How can I help you explore Laravel packages today?