PHPackages                             imliam/shareable-link - 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. imliam/shareable-link

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

imliam/shareable-link
=====================

Conveniently generate shareable URLs for various social media websites

v1.2.0(1y ago)102.5k5MITPHPPHP ^8.0

Since Jun 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ImLiam/shareable-link)[ Packagist](https://packagist.org/packages/imliam/shareable-link)[ RSS](/packages/imliam-shareable-link/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (4)Dependencies (1)Versions (7)Used By (0)

Shareable Links
===============

[](#shareable-links)

Introduction
------------

[](#introduction)

Conveniently generate shareable URLs for a variety of different social media websites, using the syntax each uses for their own links.

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

[](#installation)

You can install this package with Composer using the following command:

```
composer require imliam/shareable-link:^1.0.0
```

Example Usage
-------------

[](#example-usage)

```
$url = new \ImLiam\ShareableLink('http://example.com/', 'Example Site');

// Alternatively, with the helper function:
// shareable_link('http://example.com/', 'Example Site');

echo $url->facebook;
// https://www.facebook.com/dialog/share?app_id=ABC123&href=https://example.com/&display=page&title=Example+Site

echo $url->twitter;
// https://twitter.com/intent/tweet?url=https://example.com/&text=Example+Site

echo $url->whatsapp;
// https://wa.me/?text=Example+Site+https%3A%2F%2Fexample.com%2F

echo $url->linkedin;
// https://www.linkedin.com/shareArticle?mini=true&url=https://example.com/&summary=Example+Site

echo $url->pinterest;
// https://pinterest.com/pin/create/button/?media=&url=https://example.com/&description=Example+Site

echo $url->google;
// https://plus.google.com/share?url=https://example.com/
```

Facebook Link Notes
-------------------

[](#facebook-link-notes)

A link shareable through Facebook requires an app ID from the platform. By default, this will attempt to be obtained through a `FACEBOOK_APP_ID` environment variable. However, if this environment variable does not exist, or you need to pass through different app IDs for different URLs, you can pass one through explicitly to the `getFacebookUrl()` method.

```
$url = new \ImLiam\ShareableLink('http://example.com/', 'Example Site');

putenv('FACEBOOK_APP_ID=ABC123');

echo $url->facebook;
// https://www.facebook.com/dialog/share?app_id=ABC123&href=https://example.com/&display=page&title=Example+Site

echo $url->getFacebookUrl('XYZ789');
// https://www.facebook.com/dialog/share?app_id=XYZ789&href=https://example.com/&display=page&title=Example+Site
```

Laravel Model Trait
-------------------

[](#laravel-model-trait)

If you're using Laravel and want to be able to use these methods directly from an Eloquent model as a convenient method, you can simply create one.

The advantage of this is that you get full control over the URL and title you want to be used while still keeping a fluent syntax.

```
class News extends Model
{
    public function getShareUrlAttribute(): \ImLiam\ShareableLink
    {
        $url = route('news.show', $this->slug);

        return new \ImLiam\ShareableLink($url, $this->title);
    }
}
```

You can then proceed to use the pseudo-attribute method as you would use the normal class.

```
$news->share_url->twitter;
```

Credits
-------

[](#credits)

- [Denis Smink](https://dennissmink.nl/) for the [original article](https://medium.com/@dennissmink/laravel-shareable-trait-1a6b12a05094) that prompted this

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance45

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~612 days

Total

5

Last Release

433d ago

PHP version history (3 changes)v1.0.0PHP ^7.2

v1.1.0PHP ^7.4|^8.1

v1.2.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e8a14b9f997cf85aacea7d39da9dc33c38cc05fe03360578327ea9bcb25f4d9?d=identicon)[ImLiam](/maintainers/ImLiam)

---

Top Contributors

[![imliam](https://avatars.githubusercontent.com/u/4326337?v=4)](https://github.com/imliam "imliam (8 commits)")[![AntFuture](https://avatars.githubusercontent.com/u/98319652?v=4)](https://github.com/AntFuture "AntFuture (1 commits)")[![FutureMatt](https://avatars.githubusercontent.com/u/43476243?v=4)](https://github.com/FutureMatt "FutureMatt (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imliam-shareable-link/health.svg)

```
[![Health](https://phpackages.com/badges/imliam-shareable-link/health.svg)](https://phpackages.com/packages/imliam-shareable-link)
```

PHPackages © 2026

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