teertz / filepath
Generating a path for static files
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/teertz/filepath
Requires
- php: >=5.0
This package is not auto-updated.
Last update: 2025-10-26 01:38:19 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