承接 daylerees/sanitizer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

daylerees/sanitizer

Composer 安装命令:

composer require daylerees/sanitizer

包简介

README 文档

README

Travis Status Github Release Packagist License Packagist Downloads Github Issues Tips

Sanitizer Package

Sanitizers can be used to standardize data to ease validation, or provide data consistency.

Basic Usage

First construct a rules array.

$rules = [
    'name'      => 'trim',
    'email'     => 'trim|strtolower'
];

Rules can contain either callable functions, or the name of a sanitizer binding (more later). You can use either a pipe | or an array to specify multiple sanitization rules.

The sanitizer can be executed in the following fashion.

$sanitizer = new Sanitizer;
$sanitizer->sanitize($rules, $data);

Here's a full example.

// Construct rules array.
$rules = [
    'name'      => 'trim',
    'email'     => 'trim|strtolower'
];

// Data array to be sanitized.
$data = [
    'name' => ' Dayle ',
    'email' => ' me@DAYLEREES.com'
];

// Construct a new sanitizer.
$sanitizer = new Sanitizer;

// Execute the sanitizer.
$sanitizer->sanitize($rules, $data);

Here's the content of $data after execution.

[
    'name' => 'Dayle',
    'email' => 'me@daylerees.com'
]

Using the Laravel facade, the syntax can be made a little cleaner.

Sanitizer::sanitize($rules, $data);

Sanitize a single value like so.

$rules = 'trim|strtolower';
$data = '  Dayle';

Sanitizer::sanitizeValue($rules, $data);

Here is the value returned.

dayle

Custom Sanitization Rules

Sanitizers can be added multiple ways.

Using a Closure.

Sanitizer::register('reverse', function ($field) {
    return strrev($field);
});

Using a Callback.

Sanitizer::register('reverse', [new ClassHere, 'method']);

Using a class/method pair.

Sanitizer::register('reverse', 'Namespace\Class\Here@method');

The class will be resolved through an instance of the Illuminate IoC container, if no method is provided then sanitize() is assumed.

Installation

The Sanitizer package can be used stand-alone or with the Laravel Framework.

Stand-alone

First include the sanitizer package.

"daylerees/sanitizer": "dev-master"

Now simply use the Sanitizer class.

use Rees\Sanitizer\Sanitizer;

With Laravel

Include the Service Provider class within the app/config/app.php file.

'providers' => array(
    ...
    'Rees\Sanitizer\SanitizerServiceProvider'
)

Now simply add the facade alias.

'aliases' => array(
    ...
    'Sanitizer' => 'Rees\Sanitizer\Facade'
)

daylerees/sanitizer 适用场景与选型建议

daylerees/sanitizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127.28k 次下载、GitHub Stars 达 256, 最近一次更新时间为 2014 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 daylerees/sanitizer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 256
  • Watchers: 11
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-05-22