spatie / laravel-harvest-sdk
A Laravel-friendly SDK to interact with the Harvest API
Fund package maintenance!
Spatie
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 2
pkg:composer/spatie/laravel-harvest-sdk
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0
- saloonphp/pagination-plugin: ^2.0
- saloonphp/saloon: ^3.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2026-01-12 09:45:17 UTC
README
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
Support us
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.
Installation
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)'
Usage
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;
Users
Retrieve the authenticated user
use Spatie\Harvest\Data\UserData; use Spatie\Harvest\Facades\Harvest; $user = Harvest::users()->me()->dto(); // Returns: UserData
Retrieve all users
use Spatie\Harvest\Data\UserData; use Spatie\Harvest\Facades\Harvest; $users = Harvest::users()->all()->dto(); // Returns: array<UserData>
Projects
Retrieve all projects
use Spatie\Harvest\Data\ProjectData; use Spatie\Harvest\Facades\Harvest; $projects = Harvest::projects()->all()->dto(); // Returns: array<ProjectData>
Time Entries
Retrieve time entries
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();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.