Skip to content

Commit 965b1e7

Browse files
committed
IHF: relative_path helper readme added.
1 parent 274e255 commit 965b1e7

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Provides Laravel-specific and pure PHP helper functions.
5656
- [to_rfc2822_email](#to_rfc2822_email)
5757
- [to_swiftmailer_emails](#to_swiftmailer_emails)
5858
59+
- [Filesystem](#filesystem)
60+
- [relative_path](#relative_path)
61+
5962
- [Format](#format)
6063
- [get_dump](#get_dump)
6164
- [format_bytes](#format_bytes)
@@ -276,6 +279,26 @@ $address = to_swiftmailer_emails(['address' => '[email protected]', 'name' =>
276279
// ["[email protected]" => "John Doe"]
277280
```
278281

282+
## Filesystem
283+
284+
#### `relative_path()`
285+
286+
Returns the relative path of a directory given another one:
287+
288+
```php
289+
$path = relative_path('/var/www/htdocs', '/var/www/htdocs/example')
290+
291+
// '../'
292+
```
293+
294+
You can pass relative paths as a parameters:
295+
296+
```php
297+
$path = relative_path('/var/www/htdocs/example/public/../../', '/var/')
298+
299+
// 'www/htdocs/'
300+
```
301+
279302
## Format
280303

281304
#### `get_dump()`

tests/HelperFunctions/filesystem/RelativePathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Illuminated\Helpers\HelperFunctions\Tests\FileSystem;
3+
namespace Illuminated\Helpers\HelperFunctions\Tests\Filesystem;
44

55
use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
66

0 commit comments

Comments
 (0)