PHPackages                             sunnysideup/silverstripe-externalurlfield - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sunnysideup/silverstripe-externalurlfield

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

sunnysideup/silverstripe-externalurlfield
=========================================

Provides SilverStripe with a DBField and FormField for handling external URLs.

4.0.3(2w ago)01.1k↑46.7%11MITPHP

Since Nov 19Pushed 2w agoCompare

[ Source](https://github.com/sunnysideup/silverstripe-externalurlfield)[ Packagist](https://packagist.org/packages/sunnysideup/silverstripe-externalurlfield)[ RSS](/packages/sunnysideup-silverstripe-externalurlfield/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (12)Versions (26)Used By (1)

SilverStripe External URL Field
===============================

[](#silverstripe-external-url-field)

[![Build Status](https://camo.githubusercontent.com/eb0f4125c91f85c751e070c49aec3837189c3e2b153caf8aba77073f67b988ba/68747470733a2f2f7472617669732d63692e6f72672f73756e6e797369646575702f73696c7665727374726970652d65787465726e616c75726c6669656c642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sunnysideup/silverstripe-externalurlfield) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/02083276f763c88d2b982d2ddfab6317b3c7edc56e80b9e0ca7f4118a59a14b5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e6e797369646575702f73696c7665727374726970652d65787465726e616c75726c6669656c642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sunnysideup/silverstripe-externalurlfield/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/318819b43187d1314ef1c385749f8799c75f8ff5d17f11bedbf1bfa5da81da2c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e6e797369646575702f73696c7665727374726970652d65787465726e616c75726c6669656c642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sunnysideup/silverstripe-externalurlfield/?branch=master)

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
------------

[](#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
------------

[](#requirements)

Makes use of the `http_build_url` function from the [PECL pecl\_http library](http://php.net/manual/en/ref.http.php). However the module's composer requirements include a [PHP fallback/shim/polyfill](https://github.com/jakeasmith/http_build_url). The composer replacement does check for the presence of `http_build_url`.

- SilverStripe ^4 || ^5

DataObject / Template Usage
---------------------------

[](#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.
    );
}
```

```

    Website: $Website
    Website Nice: $Website.Nice
    Website Domain: $Website.Domain
    Website Domain No WWW: $Website.Domain.NoWWW

```

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
----------

[](#form-usage)

Handled by `ExternalURLField` (FormField).

Validation is handled by the html5 pattern attribute, and also server side by [a more robust regular expression](https://gist.github.com/dperini/729294). 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

[](#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`.

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~201 days

Recently: every ~17 days

Total

22

Last Release

20d ago

Major Versions

0.3.2 → 1.0.02023-07-11

1.0.0 → 2.0.02023-07-11

2.0.2 → 3.0.02023-10-28

3.2.1 → 6.x-dev2026-04-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/167154?v=4)[Sunny Side Up](/maintainers/sunnysideup)[@sunnysideup](https://github.com/sunnysideup)

---

Top Contributors

[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (36 commits)")[![jedateach](https://avatars.githubusercontent.com/u/1356335?v=4)](https://github.com/jedateach "jedateach (23 commits)")[![dizzystuff](https://avatars.githubusercontent.com/u/576903?v=4)](https://github.com/dizzystuff "dizzystuff (21 commits)")[![robbieaverill](https://avatars.githubusercontent.com/u/5170590?v=4)](https://github.com/robbieaverill "robbieaverill (9 commits)")[![S-GrabhamMadden](https://avatars.githubusercontent.com/u/27248899?v=4)](https://github.com/S-GrabhamMadden "S-GrabhamMadden (6 commits)")

---

Tags

urllinksilverstripeformfield

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sunnysideup-silverstripe-externalurlfield/health.svg)

```
[![Health](https://phpackages.com/badges/sunnysideup-silverstripe-externalurlfield/health.svg)](https://phpackages.com/packages/sunnysideup-silverstripe-externalurlfield)
```

###  Alternatives

[burnbright/silverstripe-externalurlfield

Provides SilverStripe with a DBField and FormField for handling external URLs.

109.6k1](/packages/burnbright-silverstripe-externalurlfield)[silverstripe/tagfield

Tag field for SilverStripe

561.3M50](/packages/silverstripe-tagfield)[lekoala/silverstripe-cms-actions

Add actions to your models in SilverStripe

39344.8k31](/packages/lekoala-silverstripe-cms-actions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
