teertz/filepath
Composer 安装命令:
composer require teertz/filepath
包简介
Generating a path for static files
关键字:
README 文档
README
Introduction
Teertz Filepath provides a simple way to generate random paths for serving big amount of static files on the server (like user images)
The generated path is like this: BASE_DIR.'/vrt/ssd/tgh/';
Basic Usage
To get started with Teertz Filepath, add to your composer.json file as a dependency:
composer require teertz/filepath
Get the full path
<?php use Teertz\Filepath\Generator as FilepathGenerator; class SomeClass { public function uploadSomePhoto($filename) { /* some work before */ $filepath = new FilepathGenerator('/var/www/static/images/'); /* some work after */ return $filepath->getFullPath().$filename; } }
You will get the BASE_DIR + random path like: /var/www/static/images/ddr/ggs/rrt/{filename}
Get generated path only
<?php use Teertz\Filepath\Generator as FilepathGenerator; class SomeClass { public function uploadSomePhoto($filename) { /* some work before */ $filepath = new FilepathGenerator('/var/www/static/images/'); /* some work after */ return $filepath->getGeneratedPath().$filename; } }
You will get the random path like: /fth/asf/bkf/{filename}
Configuration with Laravel
Add the Filepath facade to the aliases array in your app configuration file:
'Filepath' => Teertz\Filepath\Generator::class,
License
Teertz Filepath is open-sourced software licensed under the MIT license
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-08