eloquent / pathogen Goto Github PK
View Code? Open in Web Editor NEWGeneral-purpose path library for PHP.
License: MIT License
General-purpose path library for PHP.
License: MIT License
Retrieves a single atom at a given index.
Also should probably accept negative indices.
It's a common use case for paths to use ~
or ~user
to indicate home directories. Pathogen should have a system for dealing with these cases.
Some things that probably need to happen:
FileSystemPathFactoryInterface
includes methods to get the current working directory, and system temporary directory. It probably needs to be expanded to have methods to get the current home directory, and the home directory of a specified user. They should always internally use the 'platform' path factory - this just ensures that they are Windows paths on Windows, and Unix-style on anything else.FileSystem\Resolver\HomeDirectoryResolver
that implements the newly refactored PathResolverInterface
and uses an instance of PlatformFileSystemPathFactory
to produce home directory paths using the new methods created in 1. This resolver could probably cache home directory lookups, I assume they're unlikely to change at runtime.This task could be tackled at the same time as #36.
BoundPathResolverInterface
is not the best name. There are other circumstances where a path may need to be resolved without need of a base path (against the environment, for example).
Perhaps the interfaces should be PathResolverInterface
for something that simply accepts a path and returns a resolved path with no need for other parameters, and BasePathResolverInterface
for the type that takes a base path to resolve against.
Is it currently possible to do a "reverse resolving"? Get relative subdirectory path from base path and absolute path?
$basePath = '/var/www/';
$absolutePath = FileSystemPath::fromString('/var/www/project/public/index.php');
$relativePath = $absolutePath->getRelativePath($basePath);
// project/public/index.php
The github landing page for pathogen displays the dev branch and it's outdated documentation. Example: the ::fromString(...) calls we're removed some time ago, but are the main instantiation method shown on the front page's readme. Thanks!
Yes, this really is a thing. Example:
D:.\foo
means .\foo relative to the current working directory for D: drive. Windows paths have a current working directory per drive it seems. Fortunately (or unfortunately), there is no way to retrieve the CWD for a drive other than the current one via PHP.
So, in combination with #30, a few things need to happen to improve Windows path support:
Complimentary methods that convert between relative and absolute, without any resolution logic.
The previous version simply took a static 'working directory' path that never changed. Pretty useless. This version needs to implement the recently refactored PathResolverInterface
and fetch the current working directory from a PlatformFileSystemPathFactory
on each resolution. Closely tied to #33.
@darianbrown Any interest in giving this one a go?
For example, '/foo/bar/qux/doom' relative to '/foo/bar/baz/doom' currently returns '../qux'.
After some discussion, it seems to be the consensus that an absolute path should always have a drive letter, otherwise it's not truly absolute, but relative to the current drive.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.