定制 rmzamora/contact-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rmzamora/contact-bundle

Composer 安装命令:

composer require rmzamora/contact-bundle

包简介

forked version of ihqs/contact-bundle - Contact form integration for symfony

README 文档

README

Provides a simple but powerful contact form built onto the Observer Pattern. Plug any listener you want to your contact form's submission

Todo

  • Add mongodb configuration files
  • Add unit tests
  • Comment methods and attributes
  • Cleanup

(Quite the same as for GithubBundle, we are sorry for that methodology but we'll correct that soon).

Features

  • Compatible with Doctrine ORM and ODM thanks to a generic repository.
  • Model is extensible at will
  • Observer Pattern designed for more flexibility
  • Every class is customizable

Installation

Using submodules If you prefer instead to use git submodules, the run the following:

$ git submodule add git://github.com/rz/ContactBundle.git    src/Rz/ContactBundle

Using the vendors script

Add the following lines in your deps file:

[RzContactBundle]
    git=git://github.com/rz/ContactBundle.git
    target=bundles/Rz/ContactBundle

If you want to connect the email listener, install SwitfMailer and configure it

$ git submodule add git://github.com/swiftmailer.git    src/vendor/swiftmailer

or via deps file

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.2

In your config, add :

swiftmailer.config:
    transport:  smtp
    encryption: ssl
    auth_mode:  login
    host:       domain.tld
    username:   name@domain.tld
    password:   your_secret

Add the Rz namespace to your autoloader

// app/autoload.php
$loader->registerNamespaces(array(
    'Rz' => __DIR__.'/../vendor/bundles',
    // your other namespaces
);

Add ContactBundle to your application kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Rz\ContactBundle\RzContactBundle(),
        // ...
    );
}

Update your schema

app/console doctrine:schema:update --force

Adding the form to your templates

In your template, you just have to add (if you are using Twig)

{% render "RzContactBundle:Contact:form" with { 'method': app.request.method }, { 'query': app.request.request.all } %}

Since version 2.0.13 of Symfony you must send your form "POST" data using "query" parameter. That's because "render" tag is being processed as a sub-request. And since that version all sub-requests are forced to use "GET" method therefore your embedded ContactController will loose all "POST" data if you miss it. As well you should explicitly specify the request method in "method" parameter to let the embedded ContactController recognize that your form is submitted.

Configuration

In your app/config.yml (given you are using YAML for your configuration file)

rz_contact:
    contact:
        form:
            type:               rz_contact_contact
            handler:            rz_contact.contact.form.handler.default
            name:               rz_contact_contact_form
            validation_groups:  [Contact]
    form: ~                                 # (optional) class managing the contact form
    model: ~                                # (optional) class managing the model
    connectors:                             # the list of "listeners" (or connectors here)
        email:                              # connecting the email listener
            recipients: contact@rz.net    # giving him the recipient(s) email(s)
        database:                           # connecting the database listener
            db_driver: orm                  # giving him the database driver
        file: ~                             # connecting the file logger listener

If you want a simple contact form only sending an email to you contact mailbox, then you just have to add to your configuration file

rz_contact:
    connectors:
        email:
            recipients: cont@ct.me

It you want to use a custom template/view instead of the default one (RzContactBundle:Contact:form.html.twig), you can add the view parameter with the name of your view. Example:

rz_contact:
    contact:
        form:
			view:               CompanyExampleBundle:Contact:form.html.twig

Using Akismet for Spam Detection

skip the step if you dont want to check for spam, by default no spam will be detected. Install the OrnicarAkismentBundle and configure it properly. see the docs for more information.

define the service in your service container

rz_contact:
    spam_detector:
        service: ornicar_akismet

now all your Contact Request will be checked by Akismet.

if you want to implement your own Detector simply set the class for the detector

rz_contact:
    spam_detector:
        class: My\Bundle\MyDetector

note that the class should implement the SpamDetectorInterface

or if you want a whole new service:

rz_contact:
    spam_detector:
        service: my_detector_service

rmzamora/contact-bundle 适用场景与选型建议

rmzamora/contact-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「package」 「contact」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rmzamora/contact-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rmzamora/contact-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 rmzamora/contact-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-27