eheuje/pushover-bundle

提供了一些工具,用于在 symfony 2 项目中使用 Pushover

0.1.2 2016-03-28 15:18 UTC

This package is auto-updated.

Last update: 2024-09-04 20:11:17 UTC


README

提供了一些工具,用于在 symfony 2 项目中使用Pushover

什么是 Pushover?

Pushover 是一个简单的通知提供商,适用于 Android、iPhone、iPad 和桌面设备。

更多信息.

安装

  • Pushover上创建一个账户。
  • 在 Pushover 网站上创建一个应用程序以获取特定应用程序的 API 密钥
  • 下载移动应用程序并将其与您的账户同步
  • 然后,在您的 composer.json 中添加此包
$ composer require eheuje/pushover-bundle
  • 在您的 appKernel.php 中启用该包
  • 在您的 config.yml 中配置以下参数(user_keyapi_keyuser_email 由 Pushover 在您创建账户和特定应用程序后提供)
eheuje_pushover:
    application:
        user_key: <your_user_key>
        api_key: <your_api_key>
        user_email: <your_user_email>

服务

从控制器中获取服务,控制器显示“Hello World”

$this->get('eheuje_pushover.pusher')
     ->setMessage("Hello World")
     ->push();

附加信息

可以在通知中添加额外信息

  • 任务的持续时间
  • 任务使用的内存
eheuje_pushover:
    additional_information:
        duration: ~ # true or false
        memory: ~ # true or false

但是,此功能不是自动的。它与 StopWatch 组件一起工作。

关于 StopWatch 的更多信息

use Symfony\Component\Stopwatch\Stopwatch;

$stopwatch = new Stopwatch();
$stopwatch->start('eventName');
// ... some code goes here
$event = $stopwatch->stop('eventName');

$this->get('eheuje_pushover.pusher')
     ->setMessage("Hello World")
     ->setStopwatchEvent($event)
     ->push();

PushoverCommand

关于控制台组件的更多信息

当您创建大型命令时,执行它们需要很长时间。如果您不想在电脑前等待命令终止,可以将您的命令作为 PushoverCommand 的继承。

use Eheuje\PushoverBundle\Command\PushoverCommand;
use Symfony\Component\Console\Command\Command;

class GreetCommand extends PushoverCommand
{
// ... some code goes here
}

然后,使用选项 --with-pushover 调用命令。

$ php app/console foo:bar "Hello World" --with-pushover

当命令终止时,如果

  • 命令以带有预期退出码的方式终止;
  • 命令以异常终止。

待办事项列表

  • 使用 Pushover 邮件功能做些事情
  • 进行一些测试
  • 清理包