Download the PHP package telstatic/rakan without Composer

On this page you can find all versions of the php package telstatic/rakan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rakan

rakan

Laravel 文件系统扩展包 + 文件管理系统

StyleCI Shield licence licence code size downloads downloads downloads

适配阿里云OSS,七牛云

简介

通用文件管理器,支持阿里云OSS,七牛云,腾讯,华为 直传

安装

composer require telstatic/rakan

配置

修改config/filessystems.php,disk中添加
'oss' => [
    'driver' => 'oss'
],
'qiniu' => [
    'driver' => 'qiniu'
],

使用

Model user.php
<?php

namespace App\Models\User;

use TELstatic\Rakan\Traits\Rakan;
...

class User {
    use Rakan;
}

Controller FileController.php
<?php

namespace App\Http\Controller\User;

use App\Models\User;
use Illuminate\Http\Request;

class FileController {
    public $user;

    public function __constract(){
        $this->user =User::find(1); 
    }

    public function getFiles(Request $request){
        return $this->user->prefix('rakan')->module('default')->->getFiles($request);
    }

    public function getPolicy(){
        return $this->user->getPolicy();
    }

    public function createFolder(Request $request){
        return $this->user->createFolder($request->pid,$request->name);
    }

    public function deleteFiles(Request $request){
        return $this->user->deleteFiles($request->ids);
    }

    public function checkFile(Request $request){
        return $this->checkFile($request->path);
    }
}

属性

name type require default memo
prefix string true rakan 目录前缀
module string true default 模块
gateway string true oss 网关
expire int false 3600 策略有效时间

配置

name default memo
OSS_HOST null OSS上传地址
OSS_BUCKET null OSS bucket
OSS_AK null OSS access_key
OSS_SK null OSS secret_key
OSS_ENDPOINT null OSS endpoint
OSS_EXPIRE 3600 策略有效时间 单位:s
QINIU_AK null 七牛 access_key
QINIU_SK null 七牛 secret_key
QINIU_HOST null 七牛外链域名
QINIU_BUCKET null 七牛 bucket
QINIU_EXPIRE 3600 策略有效时间 单位:s

方法

参数

name type require default memo
gateway string false oss 网关 oss,qiniu 默认oss

参数

name type require default memo
prefix string false rakan 目录前缀

参数

name type require default memo
module string false default 模块名

参数

name type require default memo
pid string false 0 父级目录ID

返回 ​ 形如: ​

{
    "parent": {
        "id": "1",
        "path": "platform/q47G4R",
        "name": "Root",
        "type": "folder",
        "pid": 0,
        "module": "admin",
        "target_id": 1,
        "sort": 255,
        "updated_at": "2018-08-21 20:07:39",
        "created_at": "2018-08-21 20:07:39",
        "url": null,
        "checked": false
    },
    "children": {
        "current_page": 1,
        "data": [
            {
                "id": "2",
                "pid": "1",
                "path": "platform/q47G4R/test1",
                "name": "test1",
                "module": "admin",
                "target_id": 1,
                "type": "folder",
                "sort": 255,
                "updated_at": "2018-08-23 09:12:15",
                "created_at": "2018-08-23 09:12:15",
                "url": null,
                "checked": false
            }
        ],
        "first_page_url": "http://www.test.local/admin?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http://www.test.local/admin?page=1",
        "next_page_url": null,
        "path": "http://www.test.local/admin",
        "per_page": 50,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    }
}

参数 ​

name type require default memo
pid string true null 父级目录ID
name string true null 目录名称

返回

状态码 + 错误提示

形如: ​

{
    status:500,
    msg:'目录已存在'
}

{
    status:200,
    msg:'目录创建成功'
}

参数 ​

name type require default memo
path string true null 文件路径

返回 ​

状态码 + 错误提示

形如 ​

{
    status :500,
    msg : '文件已存在'
}

{
    status :200,
    msg : ''
}

参数

name type require default memo
ids array true null 文件或目录ID集合

返回 ​

状态 + 错误提示

形如 ​

{
    status:200,
    msg:'删除成功'
}

{
    status:500,
    msg:'目录 test 不为空'
}

返回 ​
形如 ​

{
    "data": {
        "OSSAccessKeyId": "{your-access_key}",
        "Policy": "eyleHBpcmF0aW9uIjoiMjAxOS0wMS0wM1QwMzozNTo1OFoiLCJjb25kaXRpb25zIjpbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDQ4NTc2MDAwXV19",
        "Signature": "oeE36A1SsWWBZJ6iWx3rSeSBWSQ=",
        "success_action_status": 200,
        "key": ""
    },
    "expire": "3600"
}

{
    "data": {
        "token": "JQ4aZNe87tA2FG-I01lxp7kJArP6opY_renx7MU:Tg8Zrx5XIVNY4fwhHK9nX200UcM=:eyJzY29wZSI6InRlbHN0YXRpYyIsImRlYWRsaW5lIjoxNTQ2NDg2NjE4fQ==",
        "key": ""
    },
    "expire": "3600"
}

回调路由

路由名称: rakan.callback
Tip: 将路由 rakan.callback 加入白名单

VerifyCsrfToken.php

protected $except = [
    'rakan/callback/*'
];

文件系统

    Storage::disk('qiniu')->putFileAs('avatars', new File($file), 'avatar3.jpg'); //指定文件名上传文件
    Storage::disk('qiniu')->put('avatars/avatar1.jpg', file_get_contents($file));//不指定文件名上传文件

    Storage::disk('qiniu')->prepend('file.log', 'Prepended Text');//文件头部追加
    Storage::disk('qiniu')->append('file.log', 'Appended Text');//文件尾部追加

    Storage::disk('qiniu')->copy('avatars/avatar1.jpg', 'faces/avatar1.jpg');//复制文件
    Storage::disk('qiniu')->move('avatars/avatar3.jpg', 'avatars/avatar5.jpg');//移动文件

    $visibility = Storage::disk('oss')->getVisibility('avatars/avatar5.jpg');//获取文件可见性,不支持七牛
    Storage::disk('qiniu')->setVisibility('avatars/avatar5.jpg', 'public');//设置文件可见性,不支持七牛

    Storage::disk('qiniu')->delete('avatars/avatar1.jpg');  //删除文件
    Storage::disk('qiniu')->delete(['avatars/avatar5.jpg', 'faces/avatar1.jpg']);//删除多个文件

    Storage::disk('qiniu')->makeDirectory('avatars/test');  //创建目录
    Storage::disk('qiniu')->deleteDirectory('avatars/test');  //删除目录及该目录下其他文件

    Storage::disk('qiniu')->files('/');     //获取指定目录下文件
    Storage::disk('qiniu')->allFiles('/');  //获取全部文件
    Storage::disk('qiniu')->directories('/');   //获取指定目录下目录
    Storage::disk('qiniu')->allDirectories('/');    //获取全部目录

    Storage::disk('qiniu')->exists('file.log'); //判断文件是否存在

   Storage::disk('qiniu')->get('file.log'); //获取文件内容

   Storage::disk('qiniu')->url('Pairs.jpg');    //获取文件访问地址

   Storage::disk('qiniu')->size('test/Paris.jpg');//获取文件大小
   Storage::disk('qiniu')->lastModified('test/Paris.jpg');//获取文件最后修改时间

   $file = '../public/images/faces/avatar3.jpg';

   $image_info = getimagesize($file);
   $image_data = fread(fopen($file, 'r'), filesize($file));
   $base64_image = 'data:'.$image_info['mime'].';base64,'.chunk_split(base64_encode($image_data));

   Storage::disk('oss')->base64('avatars/avatarx.jpg', $base64_image);//base64 字符串上传

对象存储支持一览

TODO

1. 云适配
    腾讯COS,又拍云,etc.
2. 多文件类型适配
    根据不同MineType类型返回不同图标

TIPS

  1. 配套前台 https://github.com/TELstatic/xayah
  2. 测试代码 https://github.com/TELstatic/RakanDemo

感谢开源

hashids/hashids

apollopy/flysystem-aliyun-oss

zgldh/qiniu-laravel-storage

参考资料

阿里云OSS PHP-SDK

七牛云对象存储 PHP-SDK

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Thanks


All versions of rakan with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
hashids/hashids Version 3.0.0
aliyuncs/oss-sdk-php Version ^2.3
league/flysystem Version ^1.0
qcloud/cos-sdk-v5 Version >=2.0
qiniu/php-sdk Version dev-master
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package telstatic/rakan contains the following files

Loading the files please wait ....