CakePHP link generator for sharing content on social networks
Clone or download
drmonkeyninja Switch to drmonkeyninja/social-share-url library (#17)
* Use drmonkeyninja/social-share-url

* Update docblock

* Update installation steps in readme
Latest commit 4331c54 Feb 8, 2018

CakePHP Social Share

Latest Stable Version License Build Status Total Downloads

This plugin provides a CakePHP View helper for creating links to share content on numerous social networks and bookmarking sites.

The aim of the plugin is to keep things simple. It doesn't come packaged with any JavaScript and I leave design decisions up to you. You can choose whether you want to use text, images, sprites or an icon font for your links.

Social Share currently supports Delicious, Digg, Evernote, Facebook, Friend Feed, Google Bookmarks, Google+, LinkedIn, Newsvine, Pinterest, Pocket, Reddit Slashdot, simple email, StumbleUpon, Technorati, Tumblr, Twitter and WhatsApp.

Note: This branch is for CakePHP 3.x.


Install using composer: composer require drmonkeyninja/cakephp-social-share:3.0.*

Then add the following line to your bootstrap.php to load the plugin.


Also don't forget to add the helper in your AppView:-




SocialShareHelper::link(string $service, string $title, mixed $url = null, array $options = [])

Returns an HTML link to share the current page for the supplied service. For example to create a link for Facebook:-

echo $this->SocialShare->link(
    __('Share on Facebook')

You can easily produce a list of links to share to different social networks:-

$services = [
    'facebook' => __('Share on Facebook'),
    'gplus' => __('Share on Google+'),
    'linkedin' => __('Share on LinkedIn'),
    'twitter' => __('Share on Twitter')

echo '<ul>';
foreach ($services as $service => $linkText) {
    echo '<li>' . $this->SocialShare->link(
    ) . '</li>';
echo '</ul>';

Supported services:-

  • delicious
  • digg
  • email
  • evernote
  • facebook
  • friendfeed
  • google (Google Bookmarks)
  • gplus (Google+)
  • linkedin
  • newsvine
  • pinterest
  • pocket
  • reddit
  • slashdot
  • stumbleupon
  • technorati
  • tumblr
  • twitter
  • whatsapp

You can pass a URL or a routing array as the third parameter for the URL you want to share.

$options supports the same options as HtmlHelper::link() as well as a 'text' option for a page title you want to include when sharing the URL. For Pinterest there is an additional 'image' option for a URL to an image to share.


SocialShareHelper::href(string $service, mixed $url = null, array $options = [])

Returns an URL for sharing to the supplied service.


SocialShareHelper::fa(string $service, mixed $url = null, array $options = [])

Returns an HTML link just like SocialShare::link() except the link text will be a relevant Font Awesome icon for the service.

For example:-

echo $this->SocialShare->fa(

Will output:-

<a href="">
    <i class="fa fa-facebook"></i>

If you need to change the icon markup output by fa() you can override the icon class using icon_class:-

echo $this->SocialShare->fa(
    ['icon_class' => 'fa fa-facebook-square']