Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Social Bundle Laravel Package

nomaya/social-bundle

NomayaSocialBundle is a Symfony bundle that adds social media buttons and share links to Twig templates through simple helpers, covering platforms like Facebook, Twitter, Google+, and Pinterest with minimal configuration.

View on GitHub
Deep Wiki
Context7

Getting Started

This is a Symfony bundle, not a Laravel package. There is no service provider or Blade integration; you either adopt the Symfony side of your stack or port the helper logic manually. Given the 13 stars and stale commit history, treat it as a reference implementation rather than a dependency you build a product on.

First steps (Symfony 2/3 era):

  1. composer require nomaya/social-bundle
  2. Register the bundle in app/AppKernel.php:
    new Nomaya\SocialButtonsBundle\NomayaSocialButtonsBundle(),
    
  3. Add minimal config in app/config/config.yml:
    nomaya_social:
        buttons:
            facebook:
                locale: "en_US"
                layout: "button_count"
            twitter:
                locale: "en"
                message: "Check this out"
    
  4. Drop a button into any Twig template:
    {{ facebookButton(app.request.uri) }}
    {{ twitterButton(app.request.uri) }}
    

Where to look first:

  • DependencyInjection/Configuration.php — the authoritative list of config keys per network; the README lags behind it.
  • Helper/SocialButtonsHelper.php — the actual markup generation. This is the file you will fork if you move to Laravel.
  • Resources/views/ — the button templates you can override.
  • Resources/config/services.yml — confirms the Twig extension and helper service IDs.

First real use case: a reusable _share.html.twig partial included at the bottom of an article template, passing app.request.uri so each post shares its own canonical URL rather than the configured default.

For Laravel: copy the helper's get*Button() methods into a small SocialButtons class, bind it as a singleton, and expose it via a Blade directive or @include partial. The generated markup is just iframes/<div>s, so framework portability is trivial — the value is in the parameter handling.

Implementation Patterns

Config defaults vs. per-call overrides. Set sensible defaults in config, then override the URL at render time so the same helper works for every page:

{{ facebookButton(absolute_url(path('article_show', {slug: article.slug}))) }}

The helper accepts an optional URL argument; if omitted it falls back to nomaya_social.buttons.facebook.url. Use the explicit form almost always.

One partial, many layouts. Wrap all networks in a single partial and include it from your base layout. This centralises CSS, CSP nonces, and consent gating:

{# templates/_social_share.html.twig #}
<div class="social-share" data-consent="marketing">
    {{ facebookButton(url) }}
    {{ twitterButton(url, message) }}
    {{ linkedinButton(url) }}
    {{ googleplusButton(url) }}
</div>

Locale per request. Override locale in the button call or via a request listener that rewrites nomaya_social.buttons.*.locale from app.request.locale. Network locales don't map 1:1 to Symfony locales — fr works for Twitter, fr_FR for Facebook/LinkedIn.

Template overrides. Symfony 2/3: copy Resources/views/*.html.twig into app/Resources/NomayaSocialButtonsBundle/views/. Symfony 4+: templates/bundles/NomayaSocialButtonsBundle/. This is the supported extension point; there's no event system worth using.

Progressive enhancement / consent. The iframes load third-party JS immediately. For GDPR you'll either gate the partial behind a consent cookie (render a placeholder until opted in) or swap the helper for a two-click solution. Do not rely on the bundle for this.

Laravel integration sketch. Extract getFacebookButton(), getTwitterButton(), etc. into app/Support/SocialButtons.php, inject config via config('services.social.*'), and register a Blade directive:

Blade::directive('facebookButton', fn ($url) => "<?php echo app(\\App\\Support\\SocialButtons::class)->facebook($url); ?>");

Gotchas and Tips

  • Not Laravel. No service provider, no config/social.php, no @facebookButton out of the box. Budget an hour for the port, or pick a maintained alternative (laravel-share, spatie/laravel-social-share style packages) if you're staying in Laravel.
  • Abandoned. No recent releases, no Symfony 5/6 Flex recipe. Composer constraints may need --ignore-platform-reqs or a fork. Pin the commit hash if you vendor it.
  • CSP will break it silently. Facebook/Twitter/LinkedIn iframes and scripts need frame-src / script-src allowances. Check the browser console first when a button renders blank.
  • GDPR. Third-party requests fire on page load. Wrap in consent logic; the bundle does not.
  • URL escaping. app.request.uri includes query strings and can leak tracking params into share links. Prefer a canonical URL (absolute_url(path(...)) or a canonical variable).
  • Locale mismatches. Invalid locale codes silently fall back to English on some networks. Verify against each network's supported list.
  • Layout quirks. Multiple iframes in a row produce inconsistent heights and baseline shifts. Normalise with flexbox and vertical-align: top.
  • Debugging config. In Symfony 3.2+ run bin/console debug:config nomaya_social to confirm merge order. In older versions, dump the container (debug:container nomaya_social_buttons.helper) — misregistered bundles cause "unknown parameter" errors at render time, not boot time.
  • Pinterest needs an image. If your content has no og:image, the button is useless; skip it or pass an explicit image URL.
  • Extension points are limited. Your only clean hooks are template overrides and service decoration of the helper. If you need behaviour changes, fork the helper — it's a few hundred lines and easier to reason about than fighting the bundle.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log