zrgisa/swiftmailerdbbundle

SwiftMailer 的数据库队列管理

安装次数: 5,354

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 18

类型:symfony-bundle

v1.0.6 2016-01-26 12:36 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:03:57 UTC


README

该插件简化了使用数据库将消息队列化与 SwiftMailer 和 Symfony2 一起使用的过程。

目前,它仅支持与 Doctrine EntityManager 和该管理器管理的实体一起使用。

安装

首先,将插件集成到您的项目中。

通过 Composer:

  1. 将以下行添加到您的 composer.json 的 require 部分

    { "require": { "whiteoctober/swiftmailerdbbundle": "1.0.1" } }

  2. 通过 Composer 下载插件

    $ php composer.phar update whiteoctober/swiftmailerdbbundle

通过 deps 文件:

  1. 在您的 deps 文件中添加以下行

    [WhiteOctoberSwiftMailerDBBundle] git=git://github.com/whiteoctober/WhiteOctoberSwiftMailerDBBundle.git target=/bundles/WhiteOctober/SwiftMailerDBBundle

Run the vendors script:

    ./bin/vendors install
  1. 将 WhiteOctober 命名空间添加到您的自动加载器

    // app/autoload.php $loader->registerNamespaces(array( 'WhiteOctober' => DIR.'/../vendor/bundles', ));

一旦您将插件下载到您的 Symfony 项目中,您需要将其添加到内核中,并添加一些配置参数,以便它知道您想使用哪个实体。

  1. 将插件添加到您的应用程序内核中

    // app/AppKernel.php public function registerBundles() { return array( // ... new WhiteOctober\SwiftMailerDBBundle\WhiteOctoberSwiftMailerDBBundle(), // ... ); }

  2. 在您的 config.yml 中配置 white_october_swift_mailer_db 服务

    white_october_swift_mailer_db: entity_class: Full\Path\To\Mail\Entity

    以下是如何构建此实体。

  3. 告诉 SwiftMailer 使用数据库队列

    swiftmailer: spool: type: db

这就是插件安装和配置的全部内容。

邮件实体

您需要创建一个可以持久化并从插件中的 EmailInterface 接口扩展的实体。目前,插件期望您的实体中存在一个名为 'status' 的属性,因为这个字段将被查询。

一旦您的实体设置完成,请使用上面详细说明的完全命名空间路径在您的 config.yml 配置中。

可选:在数据库中保留已发送的消息

默认情况下,成功发送的消息将从数据库中删除。您可以通过配置 bundle 在您的 config.yml 中保留这些消息。

white_october_swift_mailer_db:
    keep_sent_messages: true