sebastianfeldmann/camino
camino is a lightweight PHP library by Sebastian Feldmann for defining and executing command-line pipelines with clear, composable steps. It helps you build repeatable CLI workflows, handle command execution, capture output, and manage failures consistently.
Start by installing the package via Composer:
composer require sebastianfeldmann/camino
The library follows PSR-12 and is fully namespaced under SebastianFeldmann\Path. Begin with the core Path class, which encapsulates a filesystem path and exposes fluent methods for safe manipulation.
First use case: Safely join path segments while ensuring correct separator handling across Windows, macOS, and Linux:
use SebastianFeldmann\Path\Path;
$path = Path::from('app')->join('storage')->join('logs');
echo (string)$path; // 'app/storage/logs' on *nix, 'app\storage\logs' on Windows
Check the README (if available) or inspect the Path class directly via IDE navigation — it’s small and focused.
join(), append(), and prepend() to construct paths declaratively instead of using . concatenation or DIRECTORY_SEPARATOR.
$base = Path::from('/var/www');
$config = $base->append('config')->append('.env');
normalize() to resolve . and .. and collapse duplicate separators.
$path = Path::from('/foo/bar/../baz/./qux')->normalize();
echo (string)$path; // '/foo/baz/qux'
basename(), dirname(), getExtension(), isAbsolute(), isRelative() for clarity.
$path = Path::from('/path/to/file.txt');
echo $path->getExtension(); // 'txt'
echo $path->basename(); // 'file.txt'
/ or \. Camino automatically uses OS-native separators on string cast, but internally treats paths abstractly — ideal for libraries or CLI tools.Integrate with existing code by using Path::from(string|self $path) to wrap raw strings or existing Path instances, then chain operations.
Path::from('dir') does not include a trailing separator. Use trailingSeparator() if needed (check API — may require manual cast + trim() in older versions).null may throw InvalidArgumentException. Always validate inputs before constructing Path objects.Path instances are immutable. Each mutation (join, normalize, etc.) returns a new instance. Avoid reassigning variables in place... behavior in relative paths remains platform-aware — e.g., /foo/../bar normalizes to /bar on Unix, but relative paths like ../dir stay as-is unless resolved from a known base. Always normalize() when path integrity matters.getExtension() returns '' for hidden files (e.g., .env) — verify logic if handling dotfiles.AssetPath, ConfigPath) for domain clarity.🔍 Pro tip: Write tests for critical paths using both Unix and Windows-style inputs (e.g., 'C:\\foo\\bar' and '/foo/bar') to verify cross-platform normalization behavior.
How can I help you explore Laravel packages today?