PHPackages                             peal/laravel-social-share - 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. peal/laravel-social-share

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

peal/laravel-social-share
=========================

Auto Open Graph + Multi-platform sharing engine for Laravel

011PHP

Since Apr 27Pushed 2mo agoCompare

[ Source](https://github.com/moin786/laravel-social-share)[ Packagist](https://packagist.org/packages/peal/laravel-social-share)[ RSS](/packages/peal-laravel-social-share/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Social Share
====================

[](#laravel-social-share)

Smart Open Graph &amp; multi-platform social sharing engine for Laravel.

Automatically generates optimized Open Graph (OG) metadata and provides ready-to-use share links for Facebook, X (Twitter), WhatsApp, and LinkedIn.

---

✨ Features
----------

[](#-features)

- ✅ Automatic Open Graph meta generation
- ✅ Zero-configuration setup (works out of the box)
- ✅ Multi-platform sharing (Facebook, X, WhatsApp, LinkedIn)
- ✅ Smart fallback system (no broken previews)
- ✅ Clean, extensible architecture (DTO + Generators + Engines)

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require peal/laravel-social-share
```

Laravel will auto-discover the package.

---

⚙️ Publish Configuration (Optional)
-----------------------------------

[](#️-publish-configuration-optional)

```
php artisan vendor:publish --tag=social-share
```

This creates:

```
config/social-share.php
```

---

🚀 Basic Usage
-------------

[](#-basic-usage)

### 1. Add Open Graph Meta (Blade)

[](#1-add-open-graph-meta-blade)

Inside your main layout ``:

```
@include('social-share::meta', ['share' => $share ?? null])
```

---

### 2. Use in Controller

[](#2-use-in-controller)

```
use Share;

public function show(Product $product)
{
    $share = Share::for($product);

    return view('product.show', compact('product', 'share'));
}
```

---

### 3. Add Share Buttons

[](#3-add-share-buttons)

```
Facebook

X

WhatsApp

LinkedIn
```

---

🔥 Zero Configuration Mode (Auto OG Injection)
---------------------------------------------

[](#-zero-configuration-mode-auto-og-injection)

If enabled, the package can automatically inject meta tags.

### Add Middleware

[](#add-middleware)

In `app/Http/Kernel.php`:

```
protected $middlewareGroups = [
    'web' => [
        \Peal\SocialShare\Middleware\AutoShareMetaMiddleware::class,
    ],
];
```

👉 Now **no Blade or controller changes required**

---

🧠 How It Works
--------------

[](#-how-it-works)

The package automatically:

1. Detects page context
2. Generates share data:

    - title
    - description
    - image
    - URL
3. Injects Open Graph tags
4. Provides share URLs

---

⚙️ Configuration
----------------

[](#️-configuration)

```
return [
    'default_image' => '/default-share.png',
];
```

---

🛒 Example: Product Share
------------------------

[](#-example-product-share)

```
$share = Share::for($product);
```

Auto generates:

- Product name → title
- Description → trimmed
- Image → primary image
- URL → product page

---

🧩 Extending (Custom Generator)
------------------------------

[](#-extending-custom-generator)

Create your own generator:

```
class BlogShareGenerator implements ShareGenerator
{
    public function generate($post): ShareData
    {
        return ShareData::make([
            'title' => $post->title,
            'description' => $post->excerpt,
            'image' => $post->image,
            'url' => route('blog.show', $post->slug),
        ]);
    }
}
```

---

🌍 Supported Platforms
---------------------

[](#-supported-platforms)

- Facebook
- X (Twitter)
- WhatsApp
- LinkedIn

---

⚠️ Important Notes
------------------

[](#️-important-notes)

- Facebook uses Open Graph tags only
- Content preview is cached by Facebook
- Use Facebook Debugger to refresh cache

---

🚀 Laravel (Inertial, vue, react ect.)
-------------------------------------

[](#-laravel-inertial-vue-react-ect)

```
use Share;
use Inertia\Inertia;

public function show(Product $product)
{
    $share = Share::for($product);

    return Inertia::render('Product/Show', [
        'product' => $product,
        'share' => $share,
    ]);
}
```

```
import { Head } from '@inertiajs/react'

export default function Show({ product, share }) {
  return (

        {share.title}

      {product.name}

      {/* Share buttons */}
      Facebook

  )
}

```

```

import { Head } from '@inertiajs/vue3'

defineProps({
  product: Object,
  share: Object
})

    {{ share.title }}

  {{ product.name }}

```

&lt;a href={`https://www.facebook.com/sharer/sharer.php?u=${share.url}`} target="\_blank"&gt; Facebook

&lt;a href={`https://twitter.com/intent/tweet?url=${share.url}&text=${share.title}`}&gt; X

&lt;a href={`https://wa.me/?text=${share.title} ${share.url}`}&gt; WhatsApp

&lt;a href={`https://www.linkedin.com/sharing/share-offsite/?url=${share.url}`}&gt; LinkedIn

```

```

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome.

---

📄 License
---------

[](#-license)

MIT License

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance56

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/171ff00d2636607267851b5600ddb93bdeb77b62dca6f1b6c031dd6f40a3753d?d=identicon)[moin786](/maintainers/moin786)

---

Top Contributors

[![moin786](https://avatars.githubusercontent.com/u/12525167?v=4)](https://github.com/moin786 "moin786 (12 commits)")

### Embed Badge

![Health badge](/badges/peal-laravel-social-share/health.svg)

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

PHPackages © 2026

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