PHP code example of ibrand / laravel-miniprogram-poster

1. Go to this page and download the library: Download ibrand/laravel-miniprogram-poster library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ibrand / laravel-miniprogram-poster example snippets


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

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

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

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

$goods = Goods::find(1);
$result = MiniProgramShareImg::run($goods, $url,true);
 php
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,
];


php artisan vendor:publish
php artisan migrate