承接 escuelait/laravel-social-shareable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

escuelait/laravel-social-shareable

Composer 安装命令:

composer require escuelait/laravel-social-shareable

包简介

Create URLs to share content vía social networks

README 文档

README

Latest Version on Packagist Total Downloads License

A Laravel package that makes it easy to generate sharing URLs for popular social networks. Share your content on X (Twitter), Facebook, WhatsApp, LinkedIn, Pinterest, Telegram, Email, Reddit, Bluesky, and Mastodon with just a few lines of code.

Features

  • 🚀 Generate sharing URLs for 10+ social networks
  • 📱 Support for X, Facebook, WhatsApp, LinkedIn, Pinterest, Telegram, Email, Reddit, Bluesky, and Mastodon
  • 🎯 Simple and fluent API
  • 🔧 Easy to integrate with your models
  • ⚙️ Configurable (Facebook App ID support)
  • ✅ Fully tested
  • 🐘 PHP 8.1+ compatible
  • 🎗️ Laravel 10, 11, and 12 support

Installation

You can install the package via Composer:

composer require escuelait/laravel-social-shareable

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Escuelait\SocialShareable\SocialShareableServiceProvider"

Or, if you only want to publish the configuration file:

php artisan vendor:publish --tag=social-shareable-config

Update your .env file with optional Facebook App ID:

FACEBOOK_APP_ID=your_facebook_app_id_here

Usage

Using the Trait

Add the SocialShareable trait to your model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Escuelait\SocialShareable\SocialShareable;

class Post extends Model
{
    use SocialShareable;

    public $title = 'Check out this amazing post!';
    public $url = 'https://example.com/posts/1';
}

Generating Share URLs

Generate share URLs for any social network:

$post = Post::first();

// Generate share URL for X (Twitter)
$xUrl = $post->getShareUrl('x');

// Generate share URL for Facebook
$facebookUrl = $post->getShareUrl('facebook');

// Generate share URL for WhatsApp
$whatsappUrl = $post->getShareUrl('whatsapp');

// And more...
$linkedinUrl = $post->getShareUrl('linkedin');
$pinterestUrl = $post->getShareUrl('pinterest');
$telegramUrl = $post->getShareUrl('telegram');
$redditUrl = $post->getShareUrl('reddit');
$blueskyUrl = $post->getShareUrl('bluesky');
$mastodonUrl = $post->getShareUrl('mastodon');
$emailUrl = $post->getShareUrl('email');

Custom Parameters

Pass custom parameters to override defaults:

$post = Post::first();

// Custom text for X with hashtags
$xUrl = $post->getShareUrl('x', [
    'text' => 'Custom message with #hashtags',
]);

// Custom URL for Facebook
$facebookUrl = $post->getShareUrl('facebook', [
    'u' => 'https://custom-url.com',
]);

// Custom quote for LinkedIn
$linkedinUrl = $post->getShareUrl('linkedin', [
    'title' => 'Custom title for LinkedIn',
]);

Resolving Title and URL

The trait looks for $title and $url properties on your model. You can customize this by overriding the resolution methods:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Escuelait\SocialShareable\SocialShareable;

class Article extends Model
{
    use SocialShareable;

    protected function resolveShareUrl(): string
    {
        return route('articles.show', $this->slug);
    }

    protected function resolveShareTitle(): string
    {
        return $this->headline ?? $this->title;
    }
}

Supported Social Networks

The package supports the following social networks:

Network Method Description
X (Twitter) x Share on X with custom text (max 120 chars)
Facebook facebook Share on Facebook with quote and optional App ID
WhatsApp whatsapp Share via WhatsApp with title and URL
LinkedIn linkedin Share on LinkedIn with title
Pinterest pinterest Share on Pinterest with description
Telegram telegram Share via Telegram with text
Email email Share via email with subject and body
Reddit reddit Share on Reddit with title
Bluesky bluesky Share on Bluesky with text
Mastodon mastodon Share on Mastodon with text

Using the Generator Directly

You can also use the SocialShareableGenerator class directly without a model:

use Escuelait\SocialShareable\SocialShareableGenerator;

$generator = SocialShareableGenerator::for(
    'https://example.com',
    'Check this out!'
);

$xUrl = $generator->x();
$facebookUrl = $generator->facebook();
$whatsappUrl = $generator->whatsapp();

View Components (Optional)

You can create Blade components to generate share buttons:

<!-- resources/views/components/share-buttons.blade.php -->
<div class="share-buttons">
    <a href="{{ $post->getShareUrl('x') }}" target="_blank" rel="noopener noreferrer">
        Share on X
    </a>
    <a href="{{ $post->getShareUrl('facebook') }}" target="_blank" rel="noopener noreferrer">
        Share on Facebook
    </a>
    <a href="{{ $post->getShareUrl('whatsapp') }}" target="_blank" rel="noopener noreferrer">
        Share on WhatsApp
    </a>
    <a href="{{ $post->getShareUrl('linkedin') }}" target="_blank" rel="noopener noreferrer">
        Share on LinkedIn
    </a>
</div>

Testing

Run the test suite:

composer test

Requirements

  • PHP 8.1 or higher
  • Laravel 9, 10, 11, or 12
  • illuminate/support package

Changelog

See the CHANGELOG for recent changes.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This package is open-sourced software licensed under the MIT license.

Author

Miguel Angel Alvarez

Credits

Created by EscuelaIT

escuelait/laravel-social-shareable 适用场景与选型建议

escuelait/laravel-social-shareable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「share」 「shareable」 「social-network」 「escuelait」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 escuelait/laravel-social-shareable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 escuelait/laravel-social-shareable 我们能提供哪些服务?
定制开发 / 二次开发

基于 escuelait/laravel-social-shareable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-07