Git Product home page Git Product logo

jolinotif's Introduction

JoliNotif

Build Status

PHP >= 5.4

JoliNotif is a PHP library to send notifications to your desktop directly from your script. It takes care of using the right command available, without having you to worry if you're running on Linux, Windows or MacOS.

For example, if you have a long running PHP task - like executing a large test suite, launching a deployment script - you can use JoliNotif to inform yours users that a task just finished.

Installation

Use Composer to install JoliNotif in your project:

composer require "jolicode/jolinotif"

Usage

The main interface is Notifier. A NotifierFactory takes care of creating a Notifier according to which notifiers are available on your system.

Note: The factory returns null if not any notifier is supported on your system.

Look at below (or example/index.php) to see an example on how to use JoliNotif.

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\NotifierFactory;

// Create a Notifier
$notifier = NotifierFactory::create();

// Create your notification
$notification = new Notification();
$notification
    ->setTitle('I\'m a notification title')
    ->setBody('And this is the body')
    ->setIcon(__DIR__.'/notification-icon.png')
;

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

Notifier#send() will return true if the command was successfully executed, false otherwise.

Notification options

Currently, only three options are supported:

  • body
  • title
  • icon

Important: The only required property on Notification is the body. The notifier will throw an InvalidNotificationException if it is empty.

Note: If you use JoliNotif from a phar and provide a notification icon, the notification will take care to extract this image in your system temp directory to make it accessible from native commands.

Note: New properties could be added later on Notification. Notifiers are designed to handle the properties they support and discard not supported ones without throwing any exception.

Notifier supported

Currently, these notifiers are supported:

  • notify-send: should be available on most linux distributions
  • growl-notify: can be available on Mac OS X
  • terminal-notifier: can be available on Mac OS X 10.8 and higher
  • AppleScript: can display notification since Mac OS X 10.9
  • Toaster: binaries are embedded in bin/toaster so it can always be used on Windows 8 and higher
  • Notifu: binary is embedded in bin/notifu so it can always be used on Windows 7

Further documentation

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

You can find more documentation at the following links:

Credits

License

View the LICENSE file attached to this project.

jolinotif's People

Contributors

pyrech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.