PHPackages                             loka1/social-links - 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. loka1/social-links

ActiveLibrary

loka1/social-links
==================

Social links validator and sanitizer

v1.1.0(yesterday)03↑1900%PHPPHP &gt;=8.1

Since Apr 6Pushed yesterdayCompare

[ Source](https://github.com/loka1/social-links-php)[ Packagist](https://packagist.org/packages/loka1/social-links)[ RSS](/packages/loka1-social-links/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

social-links/php
================

[](#social-linksphp)

PHP library for validating, sanitizing, and detecting social media profile URLs.

Installation
------------

[](#installation)

```
composer require loka1/social-links
```

Usage
-----

[](#usage)

```
use SocialLinks\SocialLinks;
use SocialLinks\Type;

$sl = new SocialLinks();
```

### Validate a URL

[](#validate-a-url)

```
$sl->isValid('facebook', 'https://www.facebook.com/zuck');    // true
$sl->isValid('twitter', 'https://x.com/elonmusk');            // true
$sl->isValid('instagram', 'https://instagram.com/instagram'); // true
$sl->isValid('linkedin', 'https://linkedin.com/in/satyanadella'); // true
```

### Extract profile ID

[](#extract-profile-id)

```
$sl->getProfileId('facebook', 'https://www.facebook.com/zuck'); // "zuck"
$sl->getProfileId('twitter', 'https://x.com/elonmusk');         // "elonmusk"
```

### Build a canonical URL

[](#build-a-canonical-url)

```
$sl->getLink('facebook', 'zuck');                         // "https://facebook.com/zuck"
$sl->getLink('twitter', 'elonmusk');                      // "https://x.com/elonmusk"
$sl->getLink('linkedin', 'satyanadella', Type::MOBILE);   // "https://linkedin.com/mwlite/in/satyanadella"
```

### Sanitize a messy URL

[](#sanitize-a-messy-url)

```
$sl->sanitize('facebook', 'http://www.facebook.com/zuck/');          // "https://facebook.com/zuck"
$sl->sanitize('twitter', 'https://twitter.com/elonmusk');            // "https://x.com/elonmusk"
$sl->sanitize('instagram', 'https://www.instagram.com/instagram/');  // "https://instagram.com/instagram"
$sl->sanitize('linkedin', 'http://de.linkedin.com/in/loka1/');   // "https://linkedin.com/in/loka1"
```

### Auto-detect a profile

[](#auto-detect-a-profile)

```
$sl->detectProfile('https://www.facebook.com/zuck');  // "facebook"
$sl->detectProfile('https://x.com/elonmusk');         // "twitter"
$sl->detectProfile('https://instagram.com/instagram');// "instagram"
$sl->detectProfile('https://linkedin.com/in/test');   // "linkedin"
$sl->detectProfile('https://example.com');            // ""
```

### Custom profiles

[](#custom-profiles)

```
use SocialLinks\ProfileMatch;
use SocialLinks\Type;

$sl = new SocialLinks(new Config(usePredefinedProfiles: false));
$sl->addProfile('myNetwork', [
    new ProfileMatch(
        match: '(https?://)?mynetwork.com/({PROFILE_ID})/?',
        group: 2,
        type: Type::DESKTOP,
        pattern: 'https://mynetwork.com/{PROFILE_ID}',
    ),
    new ProfileMatch(
        match: '({PROFILE_ID})',
        group: 1,
    ),
]);

$sl->isValid('myNetwork', 'https://mynetwork.com/johndoe'); // true
```

### Configuration

[](#configuration)

```
use SocialLinks\Config;

// Disable predefined profiles
new SocialLinks(new Config(usePredefinedProfiles: false));

// Disable input trimming
new SocialLinks(new Config(trimInput: false));

// Allow URLs with query parameters
new SocialLinks(new Config(allowQueryParams: true));
```

Supported Networks
------------------

[](#supported-networks)

NetworkDesktopMobileFacebookfacebook.comm.facebook.comTwittertwitter.com, x.commobile.twitter.comInstagraminstagram.comm.instagram.comLinkedInlinkedin.com (with localized subdomains)linkedin.com/mwliteRequirements
------------

[](#requirements)

- PHP &gt;= 8.1
- No runtime dependencies

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

3

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34503724?v=4)[loka shafeek](/maintainers/loka1)[@loka1](https://github.com/loka1)

---

Top Contributors

[![loka1](https://avatars.githubusercontent.com/u/34503724?v=4)](https://github.com/loka1 "loka1 (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/loka1-social-links/health.svg)

```
[![Health](https://phpackages.com/badges/loka1-social-links/health.svg)](https://phpackages.com/packages/loka1-social-links)
```

PHPackages © 2026

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