anklimsk / cakephp-notify
使用任务队列发送电子邮件并使用WEB Notifications API从CakePHP 2.x向用户发送通知
v1.0.1
2018-11-19 10:40 UTC
Requires
- php: >=5.4
- anklimsk/cakephp-extended-test: ^1.0.0
- anklimsk/cakephp2-theme: ^1.0.0
- composer/installers: ^1.5.0
- dereuromark/cakephp-queue: ^2.3.0
- dereuromark/cakephp-tools: ^0.12.4
This package is auto-updated.
Last update: 2024-09-29 05:02:07 UTC
README
使用任务队列从CakePHP发送电子邮件并使用WEB Notifications API向用户发送通知
此插件提供以下功能:
- 使用任务队列从CakePHP发送电子邮件;
- 使用
Twitter Bootstrap
的内联CSS样式; - 使用WEB Notifications API通过ID或角色向用户发送通知。
安装
-
使用composer安装插件:
composer require anklimsk/cakephp-notify
-
将以下行添加到文件末尾
app/Config/bootstrap.php
CakePlugin::load('CakeNotify', ['bootstrap' => true, 'routes' => true]);
-
从
app/Plugin/CakeNotify/Config/email.php.default
复制配置文件到app/Config/email.php
-
在您的布局中添加
JavaScript
文件echo $this->Html->script('CakeNotify.WebNotifications.min.js'); // Add jQuery plugin Server-Sent Events echo $this->Html->script('CakeNotify.jquery.sse.min.js'); // If need use store configuration of plugin in storages, include file: echo $this->Html->script('CakeNotify.js.storage.min.js');
-
获取运行web服务器的用户名,运行以下命令:
ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1
。 -
配置脚本以运行计划任务,运行命令
crontab -u www-data -e
,其中www-data
是web服务器的用户名。 -
将以下行添加到cron作业列表中
# # In this example, run the cleanup script expired notifications # will be made every day on 6:00 AM 0 6 * * * cd /var/www/paht_to_app/app && Console/cake CakeNotify.cron clear -q