PHPackages                             social-links/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. social-links/social-links

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

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

PHP library to generate share buttons

v1.17.0(1y ago)112338.6k—9.4%24[3 issues](https://github.com/oscarotero/social-links/issues)2MITPHPPHP &gt;=5.3.0

Since Apr 7Pushed 1y ago6 watchersCompare

[ Source](https://github.com/oscarotero/social-links)[ Packagist](https://packagist.org/packages/social-links/social-links)[ Docs](https://github.com/oscarotero/social-links)[ RSS](/packages/social-links-social-links/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (34)Used By (2)

SocialLinks
===========

[](#sociallinks)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8d9f2b6954add19d15b610df36078b5bc032557d016ba850b46f126bd786f03f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f736361726f7465726f2f736f6369616c2d6c696e6b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/oscarotero/social-links/?branch=master)[![Build Status](https://camo.githubusercontent.com/f4a6c45abed1f9c01fb2ef8c73d2c82ef1ce2e12ee19cda611cc7c10ff0a19a3/68747470733a2f2f7472617669732d63692e6f72672f6f736361726f7465726f2f736f6369616c2d6c696e6b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/oscarotero/social-links)

Created by Oscar Otero

This is a simple library to generate buttons to share an url or count the current shares using multiple providers (facebook, twitter, etc) It also generate the appropiate meta tags to insert in the ``

Usage
-----

[](#usage)

```
use SocialLinks\Page;

//Create a Page instance with the url information
$page = new Page([
    'url' => 'http://mypage.com',
    'title' => 'Page title',
    'text' => 'Extended page description',
    'image' => 'http://mypage.com/image.png',
    'icon' => 'http://mypage.com/favicon.png',
    'twitterUser' => '@twitterUser'
]);

//Use the properties to get the providers info, for example:
$facebookProvider = $page->facebook;

//Each provider has the following info:
$page->twitter->shareUrl; //The url to share this page  (returns null if is not available)
$page->twitter->shareCount; //The number of the current shares (returns null if is not available)

//Example
$link = '%s (%s)';

printf($link, $page->facebook->shareUrl, 'Share in Facebook', $page->facebook->shareCount);
printf($link, $page->twitter->shareUrl, 'Share in Twitter', $page->twitter->shareCount);
printf($link, $page->plus->shareUrl, 'Share in Google Plus', $page->plus->shareCount);
printf($link, $page->pinterest->shareUrl, 'Share in Pinterest', $page->pinterest->shareCount);
printf($link, $page->linkedin->shareUrl, 'Share in Linkedin', $page->linkedin->shareCount);
printf($link, $page->stumbleupon->shareUrl, 'Share StumbleUpon', $page->stumbleupon->shareCount);
```

Preload share counters
----------------------

[](#preload-share-counters)

When you use, for example `$page->facebook->shareCount`, a request to facebook API is executed. This means that if you need also `$page->linkedin->shareCount` and `$page->plus->shareCount`, three requests are required. To improve performance, you can execute all these requests in parallel. Example:

```
$page = newPage(['url' => 'http://page.com']);

//Preload the counters
$page->shareCount(['linkedin', 'facebook', 'plus']);

//Use them
echo $page->facebook->shareCount;
echo $page->linkedin->shareCount;
echo $page->plus->shareCount;
```

### Providers supported

[](#providers-supported)

NameCounterblogger-bluesky-bobrdobr-cabozo-chuzaYESclassroom-delicious-digg-email-evernote-facebookYESline-linkedinYESliveinternet-livejournal-mailruYESmeneameYESodnoklassnikiYESpinterest-plusYESpocket-redditYESscoopitYESsms-stumbleuponYEStelegram-threads-tumblr-twitter-viadeo-vk-whatsapp-xingYESGenerate social meta tags
-------------------------

[](#generate-social-meta-tags)

You can use this library to generate also the tags for opengraph, twitter cards, etc. Example:

```
//$page is the same variable than the example above

//Use magic methods (instead magic properties) to get the objects with specific metas:
$card = $page->twitterCard();

//The object is traversable:
foreach($card as $tag) {
    echo $tag;
}

//You can get each tag by it's name (without prefix)
echo $card['card']; //

//Add/edit more metas
$card->addMeta('author', '@the_author'); //
```

### Meta supported

[](#meta-supported)

- html
- openGraph
- twitterCard
- schema

Usage in Symfony
----------------

[](#usage-in-symfony)

There is a Symfony bundle available here:

Contributions
-------------

[](#contributions)

- All code must be PSR-1 and PSR-2 compilance. You can use this [php cs-fixer](http://cs.sensiolabs.org/)
- The providers class names must be in lowercase starting by uppercase. For example `Linkedin` instead `LinkedIn`.
- Add the new providers to demo/index.php

Thanks to:

- [peric](https://github.com/peric) For adding Email provider and some fixes
- [eusonlito](https://github.com/eusonlito) For some fixes
- [perk](https://github.com/perk11) for adding new providers

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 81.1% 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 ~121 days

Recently: every ~434 days

Total

33

Last Release

537d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e99df56b617f4af8cf0556a51a0ca20c7420104920c57d7e9eab093f92bb744f?d=identicon)[oscarotero](/maintainers/oscarotero)

---

Top Contributors

[![oscarotero](https://avatars.githubusercontent.com/u/377873?v=4)](https://github.com/oscarotero "oscarotero (116 commits)")[![Casmo](https://avatars.githubusercontent.com/u/385764?v=4)](https://github.com/Casmo "Casmo (6 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (5 commits)")[![perk11](https://avatars.githubusercontent.com/u/1924829?v=4)](https://github.com/perk11 "perk11 (3 commits)")[![serpentblade](https://avatars.githubusercontent.com/u/1483665?v=4)](https://github.com/serpentblade "serpentblade (2 commits)")[![aschempp](https://avatars.githubusercontent.com/u/1073273?v=4)](https://github.com/aschempp "aschempp (2 commits)")[![jedkirby](https://avatars.githubusercontent.com/u/1528691?v=4)](https://github.com/jedkirby "jedkirby (2 commits)")[![alexisrazok](https://avatars.githubusercontent.com/u/8698415?v=4)](https://github.com/alexisrazok "alexisrazok (1 commits)")[![joehobson](https://avatars.githubusercontent.com/u/838671?v=4)](https://github.com/joehobson "joehobson (1 commits)")[![Metallizzer](https://avatars.githubusercontent.com/u/691719?v=4)](https://github.com/Metallizzer "Metallizzer (1 commits)")[![felcerreia](https://avatars.githubusercontent.com/u/2666386?v=4)](https://github.com/felcerreia "felcerreia (1 commits)")[![eusonlito](https://avatars.githubusercontent.com/u/644551?v=4)](https://github.com/eusonlito "eusonlito (1 commits)")[![bresam](https://avatars.githubusercontent.com/u/52054015?v=4)](https://github.com/bresam "bresam (1 commits)")[![g-rodigy](https://avatars.githubusercontent.com/u/30372087?v=4)](https://github.com/g-rodigy "g-rodigy (1 commits)")

---

Tags

counterfacebookmetadataopengraphsharetwitterfacebooktwittersocialbuttonsshareopengraphlinkstwittercards

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-social

Module containing useful widgets for Yii Framework 2.0 that integrates social functionalities from DISQUS, Facebook, Google etc.

91256.5k8](/packages/kartik-v-yii2-social)[fritzmg/contao-sharebuttons

Simple Contao extension to provide share buttons as a module and content element

1832.5k](/packages/fritzmg-contao-sharebuttons)[ryannielson/shareable

A Laravel 4 package to make it easy to add social sharing buttons to your application.

222.8k](/packages/ryannielson-shareable)[jonom/silverstripe-share-care

Social media sharing previews and customisation for Silverstripe

2932.7k1](/packages/jonom-silverstripe-share-care)[pdir/social-feed-bundle

Social feed extension for Contao CMS

1414.8k](/packages/pdir-social-feed-bundle)

PHPackages © 2026

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