Strengths:
storage_path(), public_path()) by providing pre-normalization for paths before filesystem operations.Weaknesses:
Str::of() or Filesystem facade patterns).Path::laravel() helper or facade bindings).Key Use Cases in Laravel:
../ in filenames).Storage or Filesystem classes.realpath().Pros:
require integration with Laravel’s dependency management.realpath() might fail.realpath()).Cons:
Path::join(app_path(), 'config')).Technical Risks:
\\server\share) or network drives (unsupported by this package).Path::of()), this package may become redundant.Does Laravel already solve this problem sufficiently?
Str::of() and Filesystem facade handle basic path joining, but lack cross-platform normalization (e.g., foo/../bar → bar).str_replace() + explode() manually, but this risks bugs.Is the package’s simplicity a pro or con?
How will we handle future Laravel path utilities?
What’s the migration path if this package is abandoned?
PathHelper class using preg_replace() and explode().Illuminate\Support\Path (if introduced).Does the package’s Windows drive handling meet our needs?
C:\foo/../bar → C:\bar vs. \foo/../bar → \bar (with $prependDrive=false).Laravel Compatibility:
Path) or helper (e.g., path_join()) for consistency with Laravel’s Str::, Arr::, etc.--path=foo/../bar).storage_path('app/public')).Alternatives Considered:
realpath(): Fails for non-existent paths or network drives.DIRECTORY_SEPARATOR: Manual handling is error-prone.Filesystem: Overkill for pure path normalization.Recommended Integration Points:
Filesystem to use Path::normalize() for all operations.realpath() in tests with Path::normalize().Phase 1: Proof of Concept
composer.json:
"require": {
"riimu/kit-pathjoin": "^1.2"
}
use Riimu\Kit\PathJoin\Path;
assert(Path::normalize('foo/../bar') === 'bar');
assert(Path::join(app_path(), 'config') === app_path('config'));
Phase 2: Laravel Wrapper
// app/Helpers/PathHelper.php
if (!function_exists('path_join')) {
function path_join(...$paths) {
return Path::join(...$paths);
}
}
AppServiceProvider:
Facade::register('Path', \Riimu\Kit\PathJoin\Path::class);
Phase 3: Deprecation Strategy
Illuminate\Support\Path).Path::normalize() with Unicode paths (e.g., foo/bar/ñ.txt).string if needed).realpath().\\server\share).foo/bar/ → foo/bar).Storage::put().Storage::exists()).Pros:
Cons:
create_function()).Mitigation:
composer.json with ^1.2 to block major updates.README.laravel.md.C:\foo vs. \foo).. (expected behavior).Path::normalizeForLaravel()).app('path.cache')).| Scenario | Impact | Mitigation |
|---|---|---|
| Path resolution bug | Incorrect file operations | Add validation (e.g., assert(path_is_valid())). |
| PHP 8.x incompatibility | Runtime errors |
How can I help you explore Laravel packages today?