解压插件
This commit is contained in:
parent
5ffcfaeb00
commit
6e9c8064c0
|
|
@ -37,6 +37,8 @@ class PluginController extends Controller
|
||||||
*/
|
*/
|
||||||
public function import(Request $request): array
|
public function import(Request $request): array
|
||||||
{
|
{
|
||||||
|
$zipFile = $request->file('file');
|
||||||
|
app('plugin')->import($zipFile);
|
||||||
return json_success("导入成功");
|
return json_success("导入成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@
|
||||||
|
|
||||||
namespace Beike\Plugin;
|
namespace Beike\Plugin;
|
||||||
|
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
use ZanySoft\Zip\Zip;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
{
|
{
|
||||||
|
|
@ -162,4 +164,21 @@ class Manager
|
||||||
{
|
{
|
||||||
return config('plugins.directory') ?: base_path('plugins');
|
return config('plugins.directory') ?: base_path('plugins');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传插件并解压
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function import(UploadedFile $file)
|
||||||
|
{
|
||||||
|
$originalName = $file->getClientOriginalName();
|
||||||
|
$destPath = storage_path('upload');
|
||||||
|
$newFilePath = $destPath . '/' . $originalName;
|
||||||
|
$file->move($destPath, $originalName);
|
||||||
|
|
||||||
|
Zip::check($newFilePath);
|
||||||
|
$zipFile = Zip::open($newFilePath);
|
||||||
|
$zipFile->extract(base_path('plugins'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,15 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^8.0",
|
"php": "^7.3|^8.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"intervention/image": "^2.7",
|
"intervention/image": "^2.7",
|
||||||
"laravel/framework": "^8.65",
|
"laravel/framework": "^8.65",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"stripe/stripe-php": "^8.8",
|
"stripe/stripe-php": "^8.8",
|
||||||
"tormjens/eventy": "^0.8.0"
|
"tormjens/eventy": "^0.8.0",
|
||||||
|
"zanysoft/laravel-zip": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.6",
|
"barryvdh/laravel-debugbar": "^3.6",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "4fc9f5ec868c1a2d6737b5724e42960c",
|
"content-hash": "9646e182a6e72a01992da9c58f87b3fe",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asm89/stack-cors",
|
"name": "asm89/stack-cors",
|
||||||
|
|
@ -5963,6 +5963,77 @@
|
||||||
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
|
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
|
||||||
},
|
},
|
||||||
"time": "2021-03-09T10:59:23+00:00"
|
"time": "2021-03-09T10:59:23+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "zanysoft/laravel-zip",
|
||||||
|
"version": "1.0.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/zanysoft/laravel-zip.git",
|
||||||
|
"reference": "86028aa46b234565311829dd6b62d48417335925"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/zanysoft/laravel-zip/zipball/86028aa46b234565311829dd6b62d48417335925",
|
||||||
|
"reference": "86028aa46b234565311829dd6b62d48417335925",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/support": "^6.0|^7.0|^8.0",
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"ZanySoft\\Zip\\ZipServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Zip": "ZanySoft\\Zip\\ZipFacade"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ZanySoft\\Zip\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Zany Soft",
|
||||||
|
"email": "info@zanysoft.net",
|
||||||
|
"homepage": "http://www.zanysoft.net"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "laravel-zip is the world's leading zip utility for file compression and backup.",
|
||||||
|
"homepage": "http://www.zanysoft.net",
|
||||||
|
"keywords": [
|
||||||
|
"backup",
|
||||||
|
"extract",
|
||||||
|
"laravel",
|
||||||
|
"laravel-zip",
|
||||||
|
"laravel5",
|
||||||
|
"merge",
|
||||||
|
"multiple",
|
||||||
|
"unzip",
|
||||||
|
"zip",
|
||||||
|
"ziparchive"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/zanysoft/laravel-zip/issues",
|
||||||
|
"source": "https://github.com/zanysoft/laravel-zip/tree/1.0.4"
|
||||||
|
},
|
||||||
|
"time": "2021-10-27T08:16:31+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Loading…
Reference in New Issue