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

Sharethis Widget Laravel Package

friendsofvictoire/sharethis-widget

A Laravel package for quickly integrating ShareThis social sharing widgets into Blade views. Add configurable share buttons with minimal setup, making it easy for visitors to share your content across social networks.

View on GitHub
Deep Wiki
Context7

Getting Started

First, the reality check. friendsofvictoire/sharethis-widget is not a Laravel package — it is a Symfony bundle for Victoire DCMS (FriendsOfVictoire/WidgetShareThisBundle). It ships no service provider, no config/sharethis.php, no Blade views, and no facade. Running composer require friendsofvictoire/sharethis-widget in a Laravel app will install files into vendor/ that Laravel will never autoload into a service container, because the widget class extends a Victoire base widget class that isn't installed. The only thing you get for free is a Twig template.

Where to look first. Ignore the bundle plumbing (WidgetShareThisBundle.php, DependencyInjection/, Resources/config/config.yml) — that's Victoire registration glue. Read exactly two files:

  1. Widget/ShareThisWidget.php — the widget model; in a ShareThis widget this is almost always an empty shell (no persisted fields, no business logic, just an ID and a template reference).
  2. Resources/views/Widget/ShareThisWidget.html.twig — the actual deliverable: a <div> plus the ShareThis <script> tag.

First use case is therefore a port, not an integration. Lift the markup into a Blade partial and you're done in ten minutes:

{{-- resources/views/partials/sharethis.blade.php --}}
<div class="sharethis-inline-share-buttons"
     data-url="{{ $url ?? url()->current() }}"
     data-title="{{ $title ?? '' }}"></div>

@once
    <script src="https://platform-api.sharethis.com/js/sharethis.js#property={{ config('services.sharethis.property_id') }}&product=inline-share-buttons" async></script>
@endonce
// config/services.php
'sharethis' => ['property_id' => env('SHARETHIS_PROPERTY_ID')],

Good news: the widget has no entities, no migrations, no repositories, and no routes. There is nothing to port except presentation.

Implementation Patterns

If you are staying on Symfony/Victoire: register the bundle in AppKernel/bundles.php, ensure it is enabled alongside the Victoire core bundles, and the widget shows up in the DCMS widget picker for any page slot. Configuration is done by DCMS editors, not by developers — there is no per-instance PHP config.

If you are porting to Laravel (the likely case here), mirror the widget's shape rather than its implementation:

  • Blade component over a partial. Wrap the partial in a class-based component (<x-sharethis :url="$post->canonicalUrl()" />) so the URL/title logic lives in one place and cannot drift from the markup.
  • Slot pattern. Include it from resources/views/posts/show.blade.php and any other show/detail view; pass an explicit canonical URL rather than letting each page fall back to url()->current(), which breaks with query strings and pagination.
  • Option surface. The widget's editable options in Victoire (size, networks, alignment) translate cleanly to component props: :networks="['facebook','x','linkedin']", size="large". ShareThis accepts these as data-* attributes on the container.
  • Admin surface. If you have a CMS-like back office, expose the property ID and default network set as a settings group, not as per-post fields. ShareThis state is entirely remote; nothing belongs in your content model.
  • Testing. Two assertions: the container div renders with the expected data-url, and the script tag appears exactly once when the partial is included twice on a page (@once handles same-render duplicates).

Gotchas and Tips

  • Abandonment is the headline. Last release 2016-11-16, one star, zero dependents. It targets the Symfony 2.8/3.x era and PHP 5.5–7.x. On a modern Symfony it will fight you on symfony/framework-bundle constraints and the symfony/symfony versus split-package conflict. The real blocker is Victoire's own base widget bundle, which is also dormant — you cannot simply bump a constraint.
  • Zero community support. One star and no dependents means no Stack Overflow answers, no issue-thread archaeology. Budget for reading the source yourself.
  • Consent/GDPR. The ShareThis script sets cookies on load. On a Laravel app, gate the partial behind your consent manager (e.g. only render the <script> after analytics or marketing consent is granted) or you inherit a compliance problem the 2016 bundle never considered.
  • CSP. You'll need script-src https://platform-api.sharethis.com and typically img-src/frame-src/connect-src entries for *.sharethis.com. Symptom of a missing CSP entry is a silent no-op — the div renders and nothing appears.
  • @once scoping. @once only deduplicates within a single Blade render pass. If two separate view composers or View::render calls each emit the partial, you get duplicate script tags; use a View::share flag or render the script once in the layout instead.
  • Silent failure mode. If the widget area is blank, check two things: the container has the exact class sharethis-inline-share-buttons, and the script tag is actually present in the DOM. ShareThis fails without logging anything useful.
  • Don't scrape share counts. ShareThis's count endpoints have been deprecated and rate-limited for years; if counts are a requirement, pick a different provider rather than reverse-engineering this bundle.
  • Extension points (Symfony side). In Victoire you override the widget's Twig template by placing a file at the same resource path in an app-level bundle, or subclass the widget. In Laravel, translate that to the standard publishable-views pattern: ship the partial in resources/views/vendor/sharethis/ and check there first.
  • Keep div and script together. The single most common porting bug is putting the <script> in layouts/app.blade.php and the <div> in views — the property ID then can't be overridden per page and the two drift apart on refactor.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin