teertz / filepath
Generating a path for static files
Requires
- php: >=5.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-08-30 07:02:27 UTC
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