Skip to content

Commit 84bee8c

Browse files
committed
update README.md
1 parent 49bf22b commit 84bee8c

File tree

1 file changed

+59
-20
lines changed

1 file changed

+59
-20
lines changed

README.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
# Laravel 小程序图文海报生成包
22

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

55
[![Build Status](https://travis-ci.org/ibrandcc/laravel-miniprogram-poster.svg?branch=master)](https://travis-ci.org/ibrandcc/laravel-miniprogram-poster)
66
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/?branch=master)
77
[![Code Coverage](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/?branch=master)
88
[![Build Status](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ibrandcc/laravel-miniprogram-poster/build-status/master)
99

10-
## Featrue
10+
## 特性
1111

12-
1. 基于html可实现复杂的文字,图片,阴影效果。
12+
1. 基于 html 可实现复杂的文字,图片,阴影效果。
1313
2. 清晰度和文件大小合理
1414
3. 使用简单、即插即用
15-
16-
## TODO:
17-
18-
1. 存储 Model 对象和图片对应关系,避免重复生成图片。
15+
4. 存储 Model 对象和图片对应关系,避免重复生成图片。
1916

2017
## 体验
2118

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

2421
![iBrand开源体验店](https://iyoyo.oss-cn-hangzhou.aliyuncs.com/post/miniprogramcode/1.jpg)
2522

26-
### 安装
23+
## 安装
2724
```
28-
composer require ibrand/laravel-miniprogram-poster
25+
composer require ibrand/laravel-miniprogram-poster:~2.0 -vvv
2926
```
30-
- 低于 Laravel5.5 版本,`config/app.php` 文件中 'providers' 添加`iBrand\Poster\PhantoMmagickServiceProvider::class`
27+
- 低于 Laravel5.5 版本,`config/app.php` 文件中 `providers` 添加`iBrand\Poster\PhantoMmagickServiceProvider::class`
3128

3229
- 图片保存在 `storage/app/public` 下所以需要执行 `php artisan storage:link`
3330

@@ -54,27 +51,65 @@ composer require ibrand/laravel-miniprogram-poster
5451
'quality' => 9,
5552
//是否压缩图片
5653
'compress' => true,
54+
//是否删除废弃图片文件
55+
'delete'=>true,
5756
];
5857
```
5958

60-
### 使用
59+
## 使用
60+
61+
### 定义路由和视图
62+
63+
```php
64+
Router::get('share/goods','ShareController@goods')->name('share.goods');
65+
66+
public function goods()
67+
{
68+
//你的业务逻辑代码,获取到相关数据
69+
return view('share.goods',compact('data'));
70+
}
6171
```
62-
use iBrand\Miniprogram\Poster\MiniProgramShareImg;
63-
use iBrand\Miniprogram\Poster\Poster;
64-
65-
config(['ibrand.miniprogram-poster.width' => '1300px']);
66-
$url = 'https://www.ibrand.cc/';
67-
$goods = GoodsTestModel::find(1);
68-
$result = MiniProgramShareImg::run($goods, $url);
6972

73+
这个步骤通过 Laravel 路由视图来实现海报样式展示
74+
75+
### 生成图片
76+
77+
生成图片,不关联模型。
78+
79+
```php
80+
$url = route('share.goods');
81+
$result = MiniProgramShareImg::generateShareImage($url);
82+
```
83+
84+
### 关联模型
85+
86+
执行 命令生成 `posters`
7087
```
71-
返回结果:
88+
php artisan vendor:publish
89+
php artisan migrate
90+
```
91+
92+
生成图片并关联模型
93+
```php
94+
$goods = Goods::find(1);
95+
$result = MiniProgramShareImg::run($goods, $url);
96+
```
97+
生成图片、关联模型并且重新生成图片
98+
```php
99+
$goods = Goods::find(1);
100+
$result = MiniProgramShareImg::run($goods, $url,true);
101+
```
102+
103+
104+
### 返回结果示例
72105
```
73106
[
74107
'url' => 'http://xxx.png', 图片访问url
75108
'path' => 'path/to/image', 图片文件路径
76109
]
77110
```
111+
112+
78113
### 字体安装
79114

80115
如果需要实现复杂的字体效果,需要安装字体,比如在 centos 上就没有微软雅黑的字体,所以如果生成的图片有指定的特殊字体,需要在服务器上进行安装。
@@ -98,6 +133,10 @@ mkfontdir
98133
fc-cache -fv
99134
```
100135

101-
### Resource
136+
## Resource
102137

103138
项目基于[PhantomMagick](https://github.com/anam-hossain/phantommagick)
139+
140+
## 贡献源码
141+
142+
如果你发现任何错误或者问题,请[提交ISSUE](https://github.com/ibrandcc/laravel-miniprogram-poster/issues)

0 commit comments

Comments
 (0)