<h1 align="center">
  <a href="https://github.com/jolicode/JoliNotif"><img src="https://jolicode.com/media/original/oss/headers/jolinotif.png" alt="JoliNotif"></a>
  <br />
  JoliNotif
  <br />
  <sub><em><h6>Display desktop notifications from your PHP scripts.</h6></em></sub>
</h1>

<div align="center">
    <a href="https://packagist.org/packages/jolicode/jolinotif"><img src="https://poser.pugx.org/jolicode/jolinotif/downloads" alt="Total Downloads"></img></a>
    <a href="https://packagist.org/packages/jolicode/jolinotif"><img src="https://poser.pugx.org/jolicode/jolinotif/v/stable" alt="Latest Stable Version"></img></a>
    <a href="https://packagist.org/packages/jolicode/jolinotif"><img src="https://poser.pugx.org/jolicode/jolinotif/v/unstable" alt="Latest Unstable Version"></img></a>
</div>

<br />
<br />

JoliNotif is a cross-platform PHP library to display desktop notifications.
It works on Linux, Windows (WSL included) or macOS.

<p align="center">
    <img src=doc/images/demo.gif alt="JoliNotif demo" />
</p>

Requires PHP >= 8.3 (support for previous PHP versions was available in older releases of this library).

> [!NOTE]
> This library can not be used in a web context (FPM or equivalent). Use
> it in your CLI scripts or in a [CRON](doc/04-cron-usage.md)

## Installation

Use [Composer](http://getcomposer.org/) to install JoliNotif in your project:

```shell
composer require "jolicode/jolinotif"
```

## Usage

```php
include __DIR__.'/vendor/autoload.php';

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\DefaultNotifier;

$notifier = new DefaultNotifier();

// Create your notification
$notification =
    (new Notification())
    ->setTitle('Notification title')
    ->setBody('This is the body of your notification')
    ->setIcon(__DIR__.'/path/to/your/icon.png')
    ->addOption('subtitle', 'This is a subtitle') // Only works on macOS (AppleScriptDriver)
    ->addOption('sound', 'Frog') // Only works on macOS (AppleScriptDriver & TerminalNotifierDriver)
;

// Send it
$notifier->send($notification);
```

A [shell executable](doc/05-cli-usage.md) is also provided to use JoliNotif from CLI:

```shell
jolinotif --title "Hello" --body "World"
```

## Further documentation

Discover more by reading the docs:

* [Basic usage](doc/01-basic-usage.md)
* [Notification](doc/02-notification.md)
* [Drivers](doc/03-drivers.md)
* [CRON usage](doc/04-cron-usage.md)
* [CLI usage](doc/05-cli-usage.md)

You can see the current and past versions using one of the following:

* the `git tag` command
* the [releases page on Github](https://github.com/jolicode/JoliNotif/releases)
* the file listing the [changes between versions](CHANGELOG.md)

And finally some meta documentation:

* [versioning and branching models](VERSIONING.md)
* [contribution instructions](CONTRIBUTING.md)

## Credits

* [All contributors](https://github.com/jolicode/JoliNotif/graphs/contributors)
* This project was originally inspired by [mikaelbr/node-notifier](https://github.com/mikaelbr/node-notifier)

## License

JoliNotif is licensed under the MIT License - see the [LICENSE](LICENSE) file
for details.


<br><br>
<div align="center">
<a href="https://jolicode.com/"><img src="https://jolicode.com/media/original/oss/footer-github.png?v3" alt="JoliCode is sponsoring this project"></a>
</div>
