dreams/filemanager
Composer 安装命令:
composer require dreams/filemanager
包简介
Filemanager for Laravel 5.6
README 文档
README
This package is based on: http://github.com/simogeo/Filemanager.git , and we have made modifications to encapsulate it, to get a single installable in our projects.
Once you have installed this package, you will have also all dependencies necessaries to work.
Installation
If you have composer installed globally, your need run:
composer require "dreams/filemanager"
Otherwise, you must have a composer.phar file in your base dir of your project to run:
php composer.phar require "dreams/filemanager"
Register Filemanager Provider
First, you need append the package provider to laravel providers array in the config/app.php file.
'providers' => [ // ... Dreams\Filemanager\Providers\FilemanagerProvider::class, ];
Configuration
This package, auto load/register "Gates Policies", "Routes", "Statics"... and you not need anything to work in your project.
But... you must configure the config vars to work successfully and customizing with your environment.
Running this command, the package copy (filemanager.php base config file) to laravel config dir, and you can edit this file.
php artisan vendor:publish --provider="Dreams\Filemanager\Providers\FilemanagerProvider"
Only one file, it's great!!
FileManager Config File
This is the config file, you can see a comment with an example of roles to limit user access to the filemanager.
<?php return [ // Domain of your project or one domain custom for filemanager 'domain' => env('APP_URL', 'your.domain.com'), // Prefix for url group 'prefix' => 'file-manager', // Folder to store files, normally behind of laravel public dir // Always folder tree must be start with /filemanager/userfiles/ // Example custom folder: /filemanager/userfiles/myfolder 'public_path' => '/filemanager/userfiles/', // Disable your authentication middleware if needs 'middlewares' => ['web', 'auth'], // Activate also, if you need limit user access with roles // AccessRoles Example => 'can:access-filemanager,\admin|oneRole|otherRole|anotherRole' //'middleware_access' => 'can:access-filemanager,\oneRole', // Configure to work with middleware_access, permit access to the first role of user //'roles_path' => [ // //'admin' => '/filemanager/', Equals that public_path is the base dir to other roles // 'oneRole' => '/filemanager/oneRole', // 'otherRole' => '/filemanager/otherRole', // 'anotherRole' => '/filemanager/anotherRole', //], ];
To work with roles, you need to create roles table in your database with the next structure:
UserTable
- id
- name
- email
- ... (another fileds you need)
RolesTable
- id
- name*
- ... (another fileds you need)
UserRolesTable
- id
- user_id
- role_id
* (role_name is necessary for limit access in the filemanager config file)
Then, you can access to the user role with Eloquent relations on the model:
> UserModel::class public function roles() { return $this->belongsToMany(RoleModel::class); } public function hasAnyRole(array $roles) { return null !== $this->roles()->whereIn('name', $roles)->first(); } public function hasRole($role) { return null !== $this->roles()->where('name', $role)->first(); } > RoleModel::class public function users() { return $this->belongsToMany(UserModel::class); }
And to activate user access, you need configure the middleware attributes of the config file:
// Activate also, if you need limit user access with roles // AccessRoles Example => 'can:access-filemanager,\admin|oneRole|otherRole|anotherRole' 'middleware_access' => 'can:access-filemanager,\oneRole', // Configure to work with middleware_access, permit access to the first role of user 'roles_path' => [ //'admin' => '/filemanager/', Equals that public_path is the base dir to other roles 'oneRole' => '/filemanager/oneRole', 'otherRole' => '/filemanager/otherRole', 'anotherRole' => '/filemanager/anotherRole', ],
Note1: If you only need one user access, create only admin role
Note2: If an user have multiple roles, only work's with first user role
Note3: If you not specify public_path, it will use /filemanager/
Note4: If you not specify roles_path, it will use public_path
dreams/filemanager 适用场景与选型建议
dreams/filemanager 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dreams/filemanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dreams/filemanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-28