sunnysideup/silverstripe-externalurlfield
Composer 安装命令:
composer require sunnysideup/silverstripe-externalurlfield
包简介
Provides SilverStripe with a DBField and FormField for handling external URLs.
关键字:
README 文档
README
Provides a DBField and FormField for handling external URLs.
Validate and tidy urls as they are captured from users. Configuration is highly flexible. Makes use of php's parse_url and http_build_url to do the actual work.
Installation
Note - this is forked from sunnysideup/silverstripe-externalurlfield and updated into new composer vendor namespace; making composer installs easier in client projects.
composer require sunnysideup/silverstripe-externalurlfield "*@stable"
Requirements
Makes use of the http_build_url function from the PECL pecl_http library. However the module's composer requirements include a PHP fallback/shim/polyfill. The composer replacement does check for the presence of http_build_url.
- SilverStripe ^4 || ^5
DataObject / Template Usage
Handled by ExternalURL class (Varchar).
use SilverStripe\ORM\DataObject; class MyDataObject extends DataObject { private static $db = array( 'Website' => 'ExternalURL(768)', // set a max length so that we can index it - if you do not need to index it then you may not need to add this. ); }
<% with $MyDataObject %>
<p>Website: $Website</p>
<p>Website Nice: $Website.Nice</p>
<p>Website Domain: $Website.Domain</p>
<p>Website Domain No WWW: $Website.Domain.NoWWW</p>
<% end_with %>
Given the url http://username:password@www.hostname.com:81/path?arg=value#anchor, the above produces:
Website: http://username:password@www.hostname.com:81/path?arg=value#anchor
Website Nice: www.hostname.com/path
Website Domain: www.hostname.com
Website Domain No WWW: hostname.com
Form Usage
Handled by ExternalURLField (FormField).
Validation is handled by the html5 pattern attribute, and also server side by a more robust regular expression.
The field uses the html5 type="url" attribute.
You can configure various parts of the url to be stripped out, or populated with defaults when missing.
use Sunnysideup\ExternalURLField\ExternalURLField; //default $websitefield = new ExternalURLField('Website'); //set options (with defaults shown) $websitefield->setConfig(array( //these will be added, if missing 'defaultparts' => array( 'scheme' => 'http' ), //these parts are removed from saved urls 'removeparts' => array( 'scheme' => false, 'user' => true, 'pass' => true, 'host' => false, 'port' => false, 'path' => false, 'query' => false, 'fragment' => false ), 'html5validation' => true )); //say you want to store nice tidy facebook urls $websitefield->setConfig('removeparts',array( 'query' => true, 'fragment' => 'true', 'port' => 'true' )); //a urls like https://www.facebook.com/joe.bloggs?fref=nf&pnref=story //would become https://www.facebook.com/joe.bloggs
HTML5 validation
Enabled by default, the html5 validation sets the field type atribute to url, and adds a pattern attribute which is set to https?://.+.
Disable using the html5validation config:
$field->setConfig("html5validation", false);
Disabling html5 validation is particularly useful if you want to allow users to enter urls that have no scheme/protocol e.g: mywebsite.com instead of http://www.mywebsite.com.
sunnysideup/silverstripe-externalurlfield 适用场景与选型建议
sunnysideup/silverstripe-externalurlfield 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.1k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「url」 「link」 「silverstripe」 「field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sunnysideup/silverstripe-externalurlfield 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sunnysideup/silverstripe-externalurlfield 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sunnysideup/silverstripe-externalurlfield 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A couple of handy form fields and objects for managing external and internal links on DataObjects
PHP library that allows linking queries from diferent physical databases using mysql pdo database connections
Custom links on your sidebar for Laravel Nova.
Set Links with a specific language parameter
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.
Easy URL rewrites in your Laravel application
统计信息
- 总下载量: 1.1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-30