monomelodies/formulaic
最新稳定版本:1.5.11
Composer 安装命令:
composer require monomelodies/formulaic
包简介
Object oriented PHP5 form tools
关键字:
README 文档
README
Object-oriented form utilities for PHP5.4+
This project is discontinued
Please see its successor: monolyth/formulaic
HTML forms suck. Well, no, they're superduper handy, but writing them and validating them server-side can be a pain. Formulaic offers a set of utilities to ease that pain.
Basic usage
Define a form with some fields and other requirements:
<?php use Formulaic\Get; use Formulaic\Search; use Formulaic\Button\Submit; class MyForm extends Get { public function __construct() { $this[] = (new Search('q'))->isRequired(); $this[] = new Submit('Go!', 'submit'); } }
In your template, either use the API to manually tweak your output, or simply
__toString the form to use the defaults:
<?php $form = new MyForm; echo $form;
You can __toString individual fields:
<?php $form = new MyForm; ?> <form name="search" method="get"> <!-- These two yield identical output using MyForm above: --> <?=$form[0]?> <?=$form['q']?> </form>
To validate your form:
<?php $form = new MyForm; if ($form->valid()) { // ...Perform the search... }
To get a list of errors:
<?php $form = new MyForm; if ($errors = $form->errors()) { // ...Do error handling, or give feedback... }
Forms can contain fieldsets:
<?php use Formulaic\Get; use Formulaic\Fieldset; use Formulaic\Search; use Formulaic\Button\Submit; class MyForm extends Get { public function __construct() { $this[] = new Fieldset('Global search', function($fieldset) { $fieldset[] = new Search('q'); }); $this[] = new Fieldset('Search by ID', function($fieldset) { $fieldset[] = new Search('id'); }); $this[] = new Submit('Go!'); } }
And in your output:
<form method="get"> <?=$form['Global search']?> <?=$form['Search by ID']?> <?=$form['submit']?> </form>
See the full documentation for all other options.
monomelodies/formulaic 适用场景与选型建议
monomelodies/formulaic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 175 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「form」 「HTML5」 「validation」 「oo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 monomelodies/formulaic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 monomelodies/formulaic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 monomelodies/formulaic 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HTML5 support for SilverStripe
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
A Laravel Filament Forms slug field.
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 175
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-20