midnite81 / prowl-notifications
Send notifications through the Prowl V2 and legacy V1 APIs.
Requires
- php: ^8.4
- ext-dom: *
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/psr7: ^2.7
- psr/http-client: ^1.0
- psr/http-message: ^1.1 || ^2.0
Requires (Dev)
- illuminate/container: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- laravel/pint: ^1.0
- pestphp/pest: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
midnite81/prowl-notifications sends notifications to Prowl from PHP 8.4 or later. It requires the DOM extension for legacy XML responses. Laravel support is optional.
When working from this local checkout, run composer install. In another project, you can add the checkout as a Composer path repository.
V2
use Midnite81\ProwlNotifications\Enums\Priority; use Midnite81\ProwlNotifications\Enums\SendOutcome; use Midnite81\ProwlNotifications\Notification; use Midnite81\ProwlNotifications\ProwlClient; $client = ProwlClient::v2(); // Also the default for new ProwlClient(). $result = $client->send( new Notification( apiKeys: [$apiKey], application: 'Midnite', event: 'Deployment complete', priority: Priority::Normal, ), idempotencyKey: $deploymentNotificationId, ); if ($result->outcome === SendOutcome::Accepted) { echo 'Notification accepted by Prowl.'; }
V2 requires an event. With HTTP 200, $result->recipients contains one result per input key in request order. Each has acceptedByProwl and an errorCode when Prowl provides one. The overall outcome is Accepted, PartiallyAccepted or Rejected. Acceptance describes submission to Prowl. Delivery to destinations happens separately.
The idempotency key is optional. Reuse the same key and notification when retrying the same send. Keys can contain 1–255 printable ASCII characters without spaces. The caller decides when to retry.
V1
$result = ProwlClient::v1()->send(new Notification( apiKeys: [$apiKey], application: 'Midnite', description: 'Deployment complete', ));
V1 accepts an event, a description or both. It reports a single aggregate outcome, so $result->recipients is empty. An accepted V1 submission can include invalid recipient keys when at least one key is accepted. The result includes rateLimitRemaining and rateLimitResetAt when Prowl reports them. Supplying an idempotency key to V1 raises an exception before the request.
Both clients expose httpStatus and any request-level errorCode and errorMessage in the result. Invalid input raises InvalidArgumentException, an unusable HTTP 200 response raises Midnite81\ProwlNotifications\Exceptions\InvalidResponse, and transport failures propagate as PSR-18 client exceptions. Both factories accept an optional PSR-18 HTTP client.
Laravel
Laravel package discovery registers the V2 client as a singleton. Type-hint ProwlClient in your application or resolve it from the container.
use Midnite81\ProwlNotifications\Notification; use Midnite81\ProwlNotifications\ProwlClient; $result = app(ProwlClient::class)->send(new Notification( apiKeys: [$apiKey], application: 'Midnite', event: 'Deployment complete', ));
Tests
Run composer test after installing dependencies. The Pest tests use mocked HTTP responses and require no Prowl credentials.
Run composer format to apply Pint's Laravel style or composer lint to check it.
Licence
Released under the MIT Licence.