envatic / laravel-filepond
Laravel 文件pond 上传后端模块
v1.1.2
2024-03-25 21:43 UTC
Requires
- php: ^7.0|^8.0
- illuminate/contracts: 5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/http: 5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/routing: 5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: 5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^7.5|^8.0||^9.0
- phpunit/phpunit: ^9.5|^10.5
This package is not auto-updated.
Last update: 2024-09-24 22:10:08 UTC
README
Laravel FilePond 后端
一个集成的 Laravel 后端,用于FilePond
注意
如果您正在使用 Laravel 和 Vue.js,请查看我们刚刚进入 alpha 阶段的另一个包
🚀 2 分钟内上线
Laravel 设置
在您的 Laravel 项目的 composer.json
中添加此包。
composer require sopamo/laravel-filepond
如果您需要编辑配置,可以使用以下命令发布:
php artisan vendor:publish --provider="Sopamo\LaravelFilepond\LaravelFilepondServiceProvider"
// Get the temporary path using the serverId returned by the upload function in `FilepondController.php` $filepond = app(\Sopamo\LaravelFilepond\Filepond::class); $disk = config('filepond.temporary_files_disk'); $path = $filepond->getPathFromServerId($serverId); $fullpath = Storage::disk($disk)->get($filePath); // Move the file from the temporary path to the final location $finalLocation = public_path('output.jpg'); \File::move($fullpath, $finalLocation);
外部存储
您可以使用任何Laravel 磁盘作为临时文件的存储。如果您使用不同的磁盘作为临时文件和最终位置,则需要将文件从临时位置复制到新磁盘,然后自行删除临时文件。
如果您使用默认的 local
磁盘,请确保项目中的 /storage/app/filepond 目录存在且可写。
Filepond 客户端设置
这是安装 laravel-filepond 后需要设置的最低 Filepond JS 配置。
FilePond.setOptions({ server: { url: '/filepond/api', process: '/process', revert: '/process', patch: "?patch=", headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' } } });
包开发
在提交 PR 之前,请确保所有测试都成功运行。
测试
- 使用以下命令启动 docker 容器以执行测试:
docker run -it -v $PWD:/app composer /bin/bash
- 运行
composer install
- 运行
./vendor/bin/phpunit