Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takuya/php-relative-path
calculate a relative path to path
https://github.com/takuya/php-relative-path
Last synced: 21 days ago
JSON representation
calculate a relative path to path
- Host: GitHub
- URL: https://github.com/takuya/php-relative-path
- Owner: takuya
- License: gpl-3.0
- Created: 2021-06-28T14:10:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T05:22:41.000Z (over 2 years ago)
- Last Synced: 2024-10-13T18:53:28.931Z (about 1 month ago)
- Language: PHP
- Size: 26.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-relativePath
Calculate a relative path to path
![](https://circleci.com/gh/takuya/php-relative-path.svg?style=svg)
## Get the Relative path.
This package make you get a relative path to a target.
## Equivalent to GNU realpath
This package intended to same to GNU coreuitls `realpath --relative-to`.
## Installing from github.
```composer config repositories.takuya/php-relative-path vcs https://github.com/takuya/php-relative-path
composer config minimum-stability dev
composer require takuya/php-relative-path
```
## Installing from packagist.
```sh
composer require takuya/php-relative-path
composer install
````
## Usage example.
This package provides a function `relative_path()` to your composer project.
```php
'../sites-available'
```
### example:02 file path
```php
'../sites-available/example.com'
```## run tests
```
composer install
composer dumpautoload
rm tests/sample-data.json
./vendor/bin/phpunit
```## tests results sample.
```text
Test No.01 : ./tests/Units relative-to ./tests is Units
Test No.02 : tests/Units relative-to ./tests is Units
Test No.03 : ./tests/Units relative-to tests is Units
Test No.04 : tests/Units relative-to tests is Units
Test No.05 : ./tests relative-to ./tests/Units is ..
Test No.06 : tests relative-to ./tests/Units is ..
Test No.07 : ./tests relative-to tests/Units is ..
Test No.08 : tests relative-to tests/Units is ..
Test No.09 : /usr/bin/bash relative-to /usr/local/bin is ../../bin/bash
Test No.10 : /usr/bin/bash relative-to /usr/local/bin/ is ../../bin/bash
Test No.11 : /usr/bin relative-to /usr/local/bin/ is ../../bin
Test No.12 : /usr/ relative-to /usr/local/bin/ is ../..
Test No.13 : /usr relative-to /usr/local/bin/ is ../..
Test No.14 : / relative-to /usr/local/bin is ../../..
Test No.15 : /usr/bin/php relative-to /usr/local/bin/ is ../../bin/php
Test No.16 : /usr/bin/bash relative-to /usr/local/bin/ is ../../bin/bash```