定制 th3mouk/contact-bundle 二次开发

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

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

th3mouk/contact-bundle

最新稳定版本:1.2.0

Composer 安装命令:

composer require th3mouk/contact-bundle

包简介

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

README 文档

README

This Symfony bundle providing base for manage contact form.

The aim is to factorise website contact form.

SensioLabsInsight Latest Stable Version Total Downloads Build Status Latest Unstable Version License

Installation

php composer.phar require th3mouk/contact-bundle ^1.2

Add to the appKernel.php:

new Th3Mouk\ContactBundle\Th3MoukContactBundle(),

Update your routing.yml application's file.

th3mouk_contact:
    resource: "@Th3MoukContactBundle/Resources/config/routing.yml"
    prefix:   /contact

Configure entities and templates in config.yml

th3mouk_contact:
    datas:
        from: noreply@domain.com
        to:
            - test.mail@domain.com
        subject: Contact request from your website
            
    class:
        entity: AppBundle\Entity\Contact
        formType: AppBundle\Form\ContactType

    templates:
        application: AppBundle:Contact:contact.html.twig
        mailer: AppBundle:Contact:mail.html.twig
        
    flash_messages:
        success: contact.mail.success
        error: contact.mail.error

Usage

Create Contact entity that implement the Th3Mouk\ContactBundle\Entity\ContactInterface with the app/console d:g:entity.

Generate the relative FormType: app/console d:g:f AppBundle:Contact.

Create two template for frontend and mail, you have access to form object to draw your form, and your contact object in the mail template.

Check the following exemples:

Exemple of ContactType

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ContactType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('adress')
            ->add('zipCode')
            ->add('city')
            ->add('phone')
            ->add('email', 'email')
            ->add('message')
        ;
    }

    /**
     * @param OptionsResolver $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Contact',
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'app_contact_type';
    }
}

Exemple of Form Template

<h1>Contact Request</h1>

{{ form_start(form) }}

{{ form_row(form.name) }}
{{ form_row(form.adress) }}
{{ form_row(form.zipCode) }}
{{ form_row(form.city) }}
{{ form_row(form.phone) }}
{{ form_row(form.email) }}
{{ form_row(form.message) }}

<div class="form-group"><button type="submit" class="btn-default btn">Submit</button></div>

{{ form_rest(form) }}
{{ form_end(form) }}

Exemple of Mail Template

{{ contact.name }}<br>
{{ contact.adress }}<br>
{{ contact.zipCode }}<br>
{{ contact.city }}<br>
{{ contact.phone }}<br>
{{ contact.email }}<br>
{{ contact.message }}

Sonata Integration Exemple

First use the app/console sonata:admin:generate command.

Then add the service configuration:

app.admin.contact:
    class: AppBundle\Admin\ContactAdmin
    arguments: [~, AppBundle\Entity\Contact, SonataAdminBundle:CRUD]
    tags:
        - {name: sonata.admin, manager_type: orm, label: Contacts}

Add the admin group on the dashboard:

sonata.admin.group.contact:
    label:           Contact
    label_catalogue: SonataPageBundle
    icon:            '<i class="fa fa-envelope"></i>'
    items:
        - app.admin.contact
    roles: [ ROLE_ADMIN ]

Don't forget to add this group on a block:

sonata_admin:
    dashboard:
        blocks:
            - { position: left, type: sonata.admin.block.admin_list, settings: { groups: [...sonata.admin.group.contact...] }}

You're done! 👍

Events

You have access to two events before and after mail was send :

Please

Feel free to improve this bundle.

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-07