承接 hitesh399/laravel-media 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hitesh399/laravel-media

Composer 安装命令:

composer require hitesh399/laravel-media

包简介

Laravel Media Popup to upload/view the files

README 文档

README

composer require hitesh399/laravel-media

Add the provider into the config/app.php file

Collective\Html\HtmlServiceProvider::class,
Hitesh399\LaravelMedia\LaravelMediaServiceProvider::class,

Add the alias in the config/app.php file

'Form' => Collective\Html\FormFacade::class,
'Html' => Illuminate\Support\Facades\Html::class,

To publish the vendor and update the database schema you can execute the below-mentioned commands:(You also need to install the node and npm)

php artisan vendor:publish --tag=laravel-media //to publish the vendor
php artisan migrate // update the database schema
npm install //Download and install the dependency
npm install --save-dev @fortawesome/fontawesome-free //to download font awesome

To compile the media files, add the below line into the webpack.mix.js file

require('./laravel.media.webpack.mix');

To generate the script/css execute the below mentioned command

npm run dev

Put the filesystem driver in .env file

FILESYSTEM_DRIVER=public //file driver for upload the data

Configure the config/filesystems.php as shown below

'public' => [
    'driver' => 'local',
    'root' => public_path('storage'),
    'url' => env('APP_URL').'/storage',
    'visibility' => 'public',
],

To create the storage link execute the below-mentioned command

php artisan storage:link

Define the global variable by adding below-mentioned script in between the head tag

 <script type="text/javascript">
     window.site = {
       'site_url':'{!!url('/')!!}',
       'base_url':'{!!asset('/')!!}',
       'storage_url':'{!!Storage::url('/')!!}',
       'admin_url':'{!!url('/admin')!!}',
     };

</script>

To use the media popup, include the jquery and bootstrap framework css/js files and also add the below-mentioned script file.

<script type="text/javascript" src="{!!(asset(mix('assets/js/laravel.media.min.js')))!!}"></script>

Create the Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\File;

class FileController extends Controller
{
   use \Hitesh399\LaravelMedia\Controllers\FileManager;
   public function test (Request $request) {

   	$this->validate($request, [
           'test' => 'required'
       ]);
   }
   
}

Add the below-listed line in route file to define the media routes

Route::get('files-manager','FileController@index');
Route::match(['post','get'],'files-uploader','FileController@uploader');
Route::put('make-thumb','FileController@makeThumb');
Route::get('files-list','FileController@getList');
Route::post('test-media-form','FileController@test')->name('laravel.media_test');

To get started, add the below-listed line in html file

 {!!Form::open(array('route' => 'laravel.media_test')) !!}
    {!!Form::text('username')!!}
    {!!Form::laravelMedia('image')!!}
    {!!Form::submit('Click Me!')!!}
{!!Form::close()!!}

How to use the media pop and also override the features

Use the function Form::laravelMedia($name, $label, $data, $listmaker, $htmlrender, $options)

$name [string] -> pass name of element
$label [string] -> pass the lebel of element
$listmaker[string] -> javascript function, to modify the slected file html, the callback function should be define in javascript with four arguments Like: 
function listmaker(hiddenFields, file, index, elementName) => HTML
	hiddenFields [html] -> contains the html of file hidden fields,
	file [Object] -> Object of selected file
	index [integer] -> index of selected file
	elemengtName [string] -> media field name
Note: in this function you have to renturn the HTMl
$htmlrender [string] -> javascript function, To render the prepare the html by listmaker function, function have the 3 arguments Like:
function htmlrender (html, inputName, element )
	html [HTML] -> prepare html by listmaker function
	inputName [String] -> media field name
	element [Object] instance of the media button which use to open the media popup.
$options [Array] => [
	tag [string] -> should be html tag like: button, a, span, and more
	tag_class [String] -> define the class name of media button
	thumb [Array] => [
		[
			h [String] -> define the height of thumbnail
			w [String] -> define the width of thumbnail
			title [String] ->define the title of thumbnail
		]
	]
	title [String] -> Title to diplay on the media popup
	selected_btn_text [String]  -> Selected button text 
	close_btn_text [String] -> Close button text
	maxFiles [integer] -> Max number of file.
	maxFilesize [integer] -> Max size of file in bytes 
	acceptedFiles [String] -> Accepted file type like: image/*,/png, application/*, .gif
	
]

hitesh399/laravel-media 适用场景与选型建议

hitesh399/laravel-media 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.8k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「file uploader」 「laravel upload」 「laravel media」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hitesh399/laravel-media 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hitesh399/laravel-media 我们能提供哪些服务?
定制开发 / 二次开发

基于 hitesh399/laravel-media 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-09-08