vpominchuk/laravel-easy-share
Composer 安装命令:
composer require vpominchuk/laravel-easy-share
包简介
Laravel EasyShare: Fully customized social share buttons.
README 文档
README
laravel-easy-share
Laravel EasyShare is a fully customized and easy to use social share buttons component.
It is as easy as count to four
1. Install
$ composer require vpominchuk/laravel-easy-share
2. Publish sample config file
$ php artisan vendor:publish --tag=easy-share-config
3. Add a component to your view.
<x-easy-share />
4. Add some CSS styles:
.easy-share { display: flex; } .easy-share li { margin-right: 1.5rem; }
and you are ready to go!
Available social networks
- Viber
- Telegram
Managing social networks
You can easily add/remove/enable/disable available social networks.
Just open config/easy-share.php file and add any social network you like.
Configuration options
| Option name | Description |
|---|---|
url |
Social network share url. It should include following keys: {url} - will be replaced with your. {title} - may be overwritten with your page title. {summary} - used for LinkedIn only, ok, let it be... |
allowed |
To Enable / Disable |
class |
Add any custom class to current share link |
content |
To be placed as a content for <a href=''>$content</a> tag. Can be used to display any SVG icon or other text or even HTML |
title |
To be placed as title attribute for <a href='' title='$title'>... |
Using SVG icons
To use your own SVG icons just put content of your SVG icon file into content key of configuration file for the necessary icon.
Using Fontawesome or other icons library
The same as with SVG, just put <i class="fa-brands fa-twitter"></i> into content key of the config file.
Component parameters
By default, you can use <x-easy-share /> without any attributes, it will detect current url of the page, but will not detect page title.
| Option name | Description |
|---|---|
url |
Page URL to be shared. Example: <x-easy-share url="https://example.com/" /> |
title |
Page title. Use :title="$title" to pass title from variable or title="My page title" to pass as text |
summary |
Page summary. Used for LinkedIn only. |
allow |
Allows you to enable disabled social links. Pass multiple social links via comma: allow="pinterest,reddit" |
disable |
Disable some social links. Pass multiple social links via comma: disable="pinterest,reddit" |
Custom attributes can be passed to custom template.
Using custom view (template)
To use custom template, just create a folder easy-share under resources/views/ and put your custom template in it.
<ul class="easy-share"> @foreach($services as $name => $service) <li class="easy-share-{{$name}} {{$service['class'] ?? ''}}"> <a href="{{$service['url'] ?? '#'}}" target="_blank" title="{{$service['title']}}">{!! $service['content'] ?? '' !!}</a> </li> @endforeach </ul>
Custom attributes in <x-easy-share /> component will be passed to your custom template.
All Kebab Cased and Snake Cased attributes will be transformed to Camel Case, for example:
<x-easy-share my-first-attribute="1" my_second_attribute="2" />
will be transformed to {{$myFirstAttribute}} and {{$mySecondAttribute}}.
Getting share links as a PHP array
You can use EasyShare facade to get plain PHP array of share links. Example:
use Illuminate\Support\Facades\URL; use \VPominchuk\EasyShare\Facades\EasyShare; $url = URL::current(); $easyShare = EasyShare::setUrl($url); $array = $easyShare ->setTitle($pageTitle) ->setSummary($summary) ->getServices();
There are two additional methods:
| Method | Description |
|---|---|
setAllowed(array) |
Enable some social share links. $easyShare->setAllowed(["reddit", "pinterest"]); |
disable(array) |
Disable some social share links. $easyShare->setAllowed(["reddit", "pinterest"]); |
Security
If you discover any security related issues, please use the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
vpominchuk/laravel-easy-share 适用场景与选型建议
vpominchuk/laravel-easy-share 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Laravel Social Share」 「laravel share」 「social share buttons」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vpominchuk/laravel-easy-share 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vpominchuk/laravel-easy-share 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vpominchuk/laravel-easy-share 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Improves silverstripes html meta data options.
LinkedIn integration for Social
Autogenerated open graph images for your entries.
A helper module for pdf-print, print and social share functionality based on bootstrap to custom modules.
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-09