chencha/share
Composer 安装命令:
composer require chencha/share
包简介
Share links with Laravel
README 文档
README
Share links with Laravel
This is a fork of John's share for Laravel 4.
Services available
- Blogger : blogger
- Digg : digg
- Email : email
- Evernote : evernote
- Facebook : facebook
- Gmail : gmail
- LinkedIn : linkedin
- Pinterest : pinterest
- Reddit : reddit
- Scoop.it : scoopit
- Telegram.me : telegramMe
- Tumblr : tumblr
- Twitter : twitter
- vk.com : vk
Installation
Install Composer dependency into your project
composer require chencha/share
Usage
Get a link (example with Twitter)
Route::get('/', function()
{
return Share::load('http://www.example.com', 'My example')->twitter();
});
Returns a string :
https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description
Get many links
Route::get('/', function()
{
return Share::load('http://www.example.com', 'Link description')->services('facebook', 'twitter');
});
Returns an array :
{
"twitter" : "https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description",
"facebook" : "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Link+description"
}
Get ALL the links
Route::get('/', function()
{
return Share::load('http://www.example.com', 'Link description')->services();
});
Returns an array of results for all defined services.
Customization
Publish the package config:
php artisan vendor:publish --provider='Chencha\Share\ShareServiceProvider'
Add a new service in config/social-share.php:
'mynewservice' => [ 'view' => 'share.mynewservice' ]
Add Blade templating code in share.mynewservice view file to generate a URL for mynewservice. You have access to:
- service - the service definition (shown above).
- sep - separator used between parameters, defaults to '&'. Configurable as social-share.separator.
- url - the URL being shared.
- title - the title being shared.
- media - media link being shared.
Example:
https://mynewservice.example.com?url={{ rawurlencode($url) }}<?php echo $sep; ?>title={{ rawurlencode("Check this out! $title. See it here: $url") }}
Another example for the email service. Change the service config to be [ 'view' => 'whatever' ] and put this in the view file:
mailto:?subject={{ rawurlencode("Wow, check this: $title") }}<?php echo $sep; ?>body={{ rawurlencode("Check this out! $title. See it here: $url") }}
Localizing? Easy, use Laravel's trans() call:
mailto:?subject={{ rawurlencode(trans('share.email-subject', compact('url', 'title', 'media'))) }}<?php echo $sep ?>body={{ rawurlencode(trans('share.email-body', compact('url', 'title', 'media'))) }}
Create a file at resources/lang/en/share.php with your choice of subject and body. URLs arguably have a maximum length of 2000 characters.
Notice the use of . It's the only way to print out an unencoded ampersand (if configured that way).
Upgrades
When the package is upgraded, changes to the config and views should be republished into your project:
php artisan vendor:publish --provider='Chencha\Share\ShareServiceProvider'
Use source control to work out what has changed if you have customized the files.
chencha/share 适用场景与选型建议
chencha/share 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 274.03k 次下载、GitHub Stars 达 182, 最近一次更新时间为 2015 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「share」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chencha/share 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chencha/share 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chencha/share 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Improves silverstripes html meta data options.
Autogenerated open graph images for your entries.
A helper module for pdf-print, print and social share functionality based on bootstrap to custom modules.
Yii2 widget for popular social networks 'share link' generation
share for the Yii framework
Seo Tools for Bitrix
统计信息
- 总下载量: 274.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 185
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-17