PHPackages                             ibrand/laravel-miniprogram-poster - 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. ibrand/laravel-miniprogram-poster

ActiveLibrary

ibrand/laravel-miniprogram-poster
=================================

iBrand's laravel miniprogram poster tool

v3.0(6y ago)7116.5k↑25%9[2 issues](https://github.com/guojiangclub/laravel-miniprogram-poster/issues)MITPHPPHP &gt;=7.0CI failing

Since Sep 20Pushed 4y ago3 watchersCompare

[ Source](https://github.com/guojiangclub/laravel-miniprogram-poster)[ Packagist](https://packagist.org/packages/ibrand/laravel-miniprogram-poster)[ RSS](/packages/ibrand-laravel-miniprogram-poster/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (21)Used By (0)

Laravel 小程序图文海报生成包
==================

[](#laravel-小程序图文海报生成包)

微信小程序中生成朋友圈分享图文海报一种可以实际使用的解决方案

[![Build Status](https://camo.githubusercontent.com/9f9a726d03a06b54cd03ce88c344e0a02a0078906948009eea7e786c2eb9a3d0/68747470733a2f2f7472617669732d63692e6f72672f696272616e6463632f6c61726176656c2d6d696e6970726f6772616d2d706f737465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ibrandcc/laravel-miniprogram-poster)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f6b76c4b97f644a1c35142b167dd443553d882e7c940b52c3235f6e721a67b68/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696272616e6463632f6c61726176656c2d6d696e6970726f6772616d2d706f737465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/4543f85dc6e5244cc725fc6be2d14e09baa3dc5fbb08352c7a31f3870aa44452/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696272616e6463632f6c61726176656c2d6d696e6970726f6772616d2d706f737465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/?branch=master)[![Build Status](https://camo.githubusercontent.com/a957c775ce7b9e6a5a99ef92dc710c6c43fb832bc72f2a74bc6efeb54365ef3b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696272616e6463632f6c61726176656c2d6d696e6970726f6772616d2d706f737465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/build-status/master)

特性
--

[](#特性)

1. 基于 html 可实现复杂的文字，图片，阴影效果。
2. 清晰度和文件大小合理
3. 使用简单、即插即用
4. 存储 Model 对象和图片对应关系，避免重复生成图片。

体验
--

[](#体验)

扫码进入商品详情页分享生成图文体验

[![果酱小店](https://camo.githubusercontent.com/5df6b2f1063955237cd7f6b00eff6d50ac49e2df0d094197186beb14a97bb3e4/68747470733a2f2f69796f796f2e6f73732d636e2d68616e677a686f752e616c6979756e63732e636f6d2f706f73742f6d696e6970726f6772616d636f64652f65632e7172636f64652e706e67)](https://camo.githubusercontent.com/5df6b2f1063955237cd7f6b00eff6d50ac49e2df0d094197186beb14a97bb3e4/68747470733a2f2f69796f796f2e6f73732d636e2d68616e677a686f752e616c6979756e63732e636f6d2f706f73742f6d696e6970726f6772616d636f64652f65632e7172636f64652e706e67)

安装
--

[](#安装)

```
composer require ibrand/laravel-miniprogram-poster:~2.0 -vvv

```

- 低于 Laravel5.5 版本，`config/app.php` 文件中 `providers` 添加`iBrand\Poster\PhantoMmagickServiceProvider::class`
- 图片保存在 `storage/app/public` 下所以需要执行 `php artisan storage:link`
- 如需自定义配置请执行 `php artisan vendor:publish --provider="iBrand\Poster\PhantoMmagickServiceProvider" --tag="config"`

### 配置项

[](#配置项)

```
return [
	'default'    => [
		'storage' => env('DEFAULT_POSTER_STORAGE', 'qiniu'),
	],
	//图片存储位置
	'disks'      => [
		'qiniu'            => [
			'driver'     => 'qiniu',
			//七牛云access_key
			'access_key' => env('QINIU_ACCESS_KEY', ''),
			//七牛云secret_key
			'secret_key' => env('QINIU_SECRET_KEY', ''),
			//七牛云文件上传空间
			'bucket'     => env('QINIU_BUCKET', ''),
			//七牛云cdn域名
			'domain'     => env('QINIU_DOMAIN', ''),
			//与cdn域名保持一致
			'url'        => env('QINIU_DOMAIN', ''),
			'root'       => storage_path('app/public/qiniu'),
		],
		'MiniProgramShare' => [
			'driver'     => 'local',
			'root'       => storage_path('app/public/share'),
			'url'        => env('APP_URL') . '/storage/share',
			'visibility' => 'public',
		],
	],
	//图片宽度
	'width'      => '575px',
	//放大倍数
	'zoomfactor' => 1.5,
	//1-9,9质量最高
	'quality'    => 9,
	//是否压缩图片
	'compress'   => true,
	//是否删除废弃图片文件
	'delete'     => true,
];
```

注：生成海报默认存储七牛云，通过配置项`default.storage`来设置，如果不适用七牛云，可以通过修改`.env`中`DEFAULT_POSTER_STORAGE`来修改默认存储storage

使用
--

[](#使用)

### 定义路由和视图

[](#定义路由和视图)

```
Router::get('share/goods','ShareController@goods')->name('share.goods');

public function goods()
{
	//你的业务逻辑代码，获取到相关数据
    return view('share.goods',compact('data'));
}
```

这个步骤通过 Laravel 路由视图来实现海报样式展示

### 生成图片

[](#生成图片)

生成图片，不关联模型。

```
$url = route('share.goods');
$result = MiniProgramShareImg::generateShareImage($url);
```

### 关联模型

[](#关联模型)

执行 命令生成 `posters`表

```
php artisan vendor:publish
php artisan migrate

```

生成图片并关联模型

```
$goods = Goods::find(1);
$result = MiniProgramShareImg::run($goods, $url);
```

生成图片、关联模型并且重新生成图片

```
$goods = Goods::find(1);
$result = MiniProgramShareImg::run($goods, $url,true);
```

### 返回结果示例

[](#返回结果示例)

```
    [
        'url'  => 'http://xxx.png',   图片访问url
        'path' => 'path/to/image', 图片文件路径
    ]

```

### 字体安装

[](#字体安装)

如果需要实现复杂的字体效果，需要安装字体，比如在 centos 上就没有微软雅黑的字体，所以如果生成的图片有指定的特殊字体，需要在服务器上进行安装。

- window 将下载的字体文件复制到C:Windows\\Fonts目录下或者双击字体文件进行安装
- mac 下载的字体文件 双击字体文件进行安装
- centos

```
# 安装微软雅黑
wget -P /tmp/ https://iyoyo.oss-cn-hangzhou.aliyuncs.com/mirror/fonts/msyh.ttf
wget -P /tmp/ https://iyoyo.oss-cn-hangzhou.aliyuncs.com/mirror/fonts/msyhbd.ttf
wget -P /tmp/ https://iyoyo.oss-cn-hangzhou.aliyuncs.com/mirror/fonts/msyhl.ttf
cd /usr/share/fonts/lyx/
mkdir chinese
cd chinese
mv /tmp/msyhbd.ttf ./
chmod 755 *.ttf
yum -y install mkfontscale
mkfontscale
mkfontdir
fc-cache -fv

```

Resource
--------

[](#resource)

项目基于[PhantomMagick](https://github.com/anam-hossain/phantommagick)

贡献源码
----

[](#贡献源码)

如果你发现任何错误或者问题，请[提交ISSUE](https://github.com/ibrandcc/laravel-miniprogram-poster/issues)

果酱云社区
-----

[](#果酱云社区)

 [ ![点击跳转](https://camo.githubusercontent.com/6359e5bd680f99c0f946287e22a32d5935d94a942ae2116a0b2f6f0c7a70ccca/68747470733a2f2f63646e2e67756f6a69616e672e636c75622f696d6167652f323032322f30322f31362f77755f316673306a62636f32313832673238306c317661676d376265362e706e67) ](https://guojiang.club/)

- 全网真正免费的IT课程平台
- 专注于综合IT技术的在线课程，致力于打造优质、高效的IT在线教育平台
- 课程方向包含Python、Java、前端、大数据、数据分析、人工智能等热门IT课程
- 300+免费课程任你选择

 [ ![点击跳转](https://camo.githubusercontent.com/8f168577f9682601d01cf6c726dbbccd911815b2b6d4f999e27475448f22a107/68747470733a2f2f63646e2e67756f6a69616e672e636c75622f696d6167652f323032322f30322f31362f77755f316673306c383261653170713131653433316a366e31376a7331767137362e706e67) ](https://guojiang.club/)

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~44 days

Recently: every ~150 days

Total

19

Last Release

1985d ago

Major Versions

v1.3.1 → 2.x-dev2018-11-29

v2.8.1 → v3.02019-06-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/05a4dd937f49471fe1d2cb4da6445668df23b2ad2422789b3aaed3ef9459c377?d=identicon)[shjchen](/maintainers/shjchen)

---

Top Contributors

[![tangqi1916](https://avatars.githubusercontent.com/u/193469035?v=4)](https://github.com/tangqi1916 "tangqi1916 (36 commits)")[![chenbidepro](https://avatars.githubusercontent.com/u/9166101?v=4)](https://github.com/chenbidepro "chenbidepro (13 commits)")

---

Tags

laravellaravel-packageminiprogramphpcomponentibrandposterminiprogram

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ibrand-laravel-miniprogram-poster/health.svg)

```
[![Health](https://phpackages.com/badges/ibrand-laravel-miniprogram-poster/health.svg)](https://phpackages.com/packages/ibrand-laravel-miniprogram-poster)
```

###  Alternatives

[ibrand/pay

ibrand pay component

1315.9k](/packages/ibrand-pay)

PHPackages © 2026

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