peter9x / laravel-provet-api
Laravel package for Provet API
v1.0.1
2026-07-22 22:35 UTC
Requires
- php: ^8.2
- ext-curl: *
- ext-fileinfo: *
- ext-json: *
- guzzlehttp/guzzle: 7.x
- illuminate/cache: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- league/oauth2-client: ^2
Requires (Dev)
- laravel/pint: ^1.24
- orchestra/testbench: ^10.4|^11.0
- pestphp/pest: ^v2.34|^3.7
- phpunit/phpunit: ^11.5
- spatie/laravel-health: ^1.40
Suggests
- spatie/laravel-health: Allows monitoring Business Central connections via the Mupy\BusinessCentral\HealthChecks\BusinessCentralCheck health check (spatie/laravel-health).
README
Laravel Provet API
A Laravel package for communicating with the Provet Cloud API.
Features
- OAuth2 client-credentials authentication with token caching
- Multiple named connections (multi-tenant / multi-organization support)
- Typed, capability-safe resource path builders (
Client::all(),Patient::get(42), ...) - Fluent filter/pagination query builder
- Automatic retries with 401/429 handling
- Lazy, memory-safe pagination for large datasets
- Laravel Facade
Installation
composer require peter9x/laravel-provet-api
php artisan vendor:publish --provider="Mupy\\ProvetApi\\ProvetServiceProvider" --tag=config
Configuration
Set your Provet credentials in .env:
PROVET_ID=7456 PROVET_CLIENT_ID=your-client-id PROVET_CLIENT_SECRET=your-client-secret
For multiple tenants/organizations, add one entry per connection in config/provet.php:
'default' => env('PROVET_CONNECTION', '7456'), 'connections' => [ '7456' => [ 'client_id' => env('PROVET_API_7456_ID'), 'client_secret' => env('PROVET_API_7456_SECRET'), ], '2449' => [ 'client_id' => env('PROVET_API_2449_ID'), 'client_secret' => env('PROVET_API_2449_SECRET'), ], ],
Usage
use Mupy\ProvetApi\Facades\Provet; use Mupy\ProvetApi\Paths\Client; use Mupy\ProvetApi\Paths\Query; use Mupy\ProvetApi\Enums\Operator; // Retrieve $client = Provet::get(Client::get(42)); // List, with filters, ordering and pagination $query = (new Query()) ->where('email', Operator::ICONTAINS, 'acme') ->orderByDesc('created') ->perPage(50); $clients = Provet::get(Client::all($query)); // Create / update / delete (only exposed on resources the API actually supports) Provet::post(Client::create(), ['firstname' => 'Ada']); Provet::patch(Client::update(42), ['firstname' => 'Ada Lovelace']); Provet::delete(Client::delete(42));
Dependency injection
ProvetClient is bound as a singleton, so it can be injected instead of using the facade:
use Mupy\ProvetApi\ProvetClient; use Mupy\ProvetApi\Paths\Client; class SyncClientsController { public function __construct( private readonly ProvetClient $provet, ) {} public function __invoke(int $id) { // Pass a connection name to use a tenant other than the default one. return $this->provet->connection('2449')->get(Client::get($id)); } }
Multiple connections
Provet::connection('2449')->get(Client::all());
Pagination
paginate() streams results lazily, following the API's next links, so it's safe for endpoints with millions of records:
use Mupy\ProvetApi\Paths\Invoice; foreach (Provet::paginate(Invoice::all()) as $invoice) { // one invoice at a time, no buffering } // Or with a stop condition and progress tracking: Provet::paginate(Invoice::all()) ->onPageEnd(fn ($page) => logger()->info("page done, next: {$page->next}")) ->each(function ($invoice) { // return false to stop early });