filp/nod

PHP中的通知(notify-send、growl等)。

dev-master 2012-08-29 13:19 UTC

This package is not auto-updated.

Last update: 2024-09-14 12:41:36 UTC


README

PHP中的通知(notify-send, growl, etc)就像这样。

##示例

Nod确定最佳适配器(目前不推荐,仅适用于某些Linux环境)。

#!/usr/bin/env php
<?php  

$notification = new Nod\Notification;
$notification
  ->setTitle('My rad notification')
  ->setMessage('Check it.')
  ->setUrgency('high')
  ->setExpiry(3000)
  ->setIcon('emblem-favorite.png')
  ->send();

明确地为Nod提供一个适配器进行工作。

#!/usr/bin/env php
<?php  

use Nod\Adapter\Terminal as TerminalAdapter;

$notification = new Nod\Notification(new TerminalAdapter);
$notification
  ->setTitle('Look at ya')
  ->setMessage('Let me see what ya got')
  // you can also specify the expiry directly in the send() method:
  ->send(5000);

创建自己的适配器就像实现Nod\Adapter\AdapterInterface一样简单。

<?php

namespace Nod\Adapter;
interface AdapterInterface
{
    /* bool */ public function canNotify();
    /* bool */ public function process($title, $message, $urgency, $expiry, $icon);
}

##安装

Nod可以通过composerpackagist页面)使用,只需将filp/nod添加到您的composer.json文件中即可。

{
    "require" : {
        "filp/nod" : "dev-master"
    }
}

Nod库可以直接通过composer自动加载器加载,或者使用任何兼容PSR-0的自动加载器。

##待办事项、愿望清单等

  • 平台支持(MacOS growl、Windows growl等)。
  • 单元测试(即将推出!)
  • 更多适配器,用于各种奇特的工具。