da-vinci-studio/path-generator
Generate consistent file and directory paths in your Laravel app with configurable patterns and helpers. Useful for organizing uploads, storage, and assets by date, model, or custom rules, keeping paths predictable and easy to change later.
Illuminate\Filesystem). Direct integration may require wrappers or adapters.config/filesystems.php). Assess whether the package’s logic aligns with Laravel’s conventions (e.g., storage_path(), public_path()).Str::slug(), Str::uuid(), or Storage facade may suffice. Evaluate whether the package adds unique value (e.g., namespace collision avoidance, multi-tenancy support).sprintf-style path concatenation instead of sprintf() or sprintf() alternatives). Risk of breaking changes in future Laravel upgrades.Str::of() or Filesystem::exists() checks.Storage, Str::) or packages like spatie/laravel-medialibrary for path generation?Storage facade to abstract path generation from the underlying driver (local, cloud, etc.). Example:
use Illuminate\Support\Facades\Storage;
// Hypothetical wrapper around the package
class PathGeneratorService {
public function generate(string $basePath, string $filename): string {
$rawPath = PathGenerator::generate($basePath, $filename); // Original package
return Storage::disk('public')->url($rawPath); // Laravel integration
}
}
$this->app->bind(PathGenerator::class, function () {
return new PathGenerator(config('path-generator.settings'));
});
Storage::put()).fruitcake/laravel-cors for path utilities).Storage::disk('s3')->url($generatedPath);
// config/path-generator.php
return [
'prefix' => 'uploads/{tenant_id}/',
];
Log facade.composer.json to avoid accidental upgrades. Monitor for security advisories (though unlikely given inactivity).sprintf for path formatting").$path = Cache::remember("path_{$filename}", now()->addHours(1), function () use ($filename) {
return $this->pathGenerator->generate('uploads', $filename);
});
/ vs. local DIRECTORY_SEPARATOR).Str::of() or Str::contains() checks to prevent traversal attacks.Storage::makeDirectory() to pre-create paths:
Storage::disk('public')->makeDirectory(dirname($path));
assert(Storage::exists($path), "Path generation failed for {$filename}");
php artisan test --filter PathGeneratorTest).How can I help you explore Laravel packages today?