Skip to content

Commit 2e4becc

Browse files
prepare PHP Path
1 parent 3c53651 commit 2e4becc

File tree

8 files changed

+168
-137
lines changed

8 files changed

+168
-137
lines changed

.mailmap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Shahzada Modassir <modassirdev@gmail.com>
1+
Shahzada Modassir <shahzadamodassir@gmail.com>
22
Shahzadi Afsara <shahzadiafsara@gmail.com>

AUTHORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Shahzada Modassir <modassirdev@gmail.com>
1+
Shahzada Modassir <shahzadamodassir@gmail.com>
22
Shahzadi Afsara <shahzadiafsara@gmail.com>

CHANGELOG.md

+1-90
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,2 @@
11
# Release Notes
2-
## [Unreleased](https://github.com/lazervel/path/compare/v9.2.0...v10.0.0)
3-
4-
## [10.0.0](https://github.com/lazervel/path/compare/v9.2.0...v10.0.0) - 15 November 2024
5-
- [BC BREAK] Since v8.x, Due to significant updates in the library, all previous configurations may no longer work as expected. Users will need to reconfigure their settings to align with the new structure and behavior introduced in this update.
6-
- Review the updated documentation for `Path` to understand the new behavior.
7-
- Ensure that any calls to these methods are updated to accommodate these changes.
8-
- Affected `Path::canonicalize()` of output behaviour.
9-
- Affected `Path::resolve()` of output behaviour.
10-
- Affected `Path::normalize()` of output behaviour.
11-
- Affected `Path::optimize()` of output behaviour.
12-
- Affected `Path::join()` of output behaviour.
13-
- Affected `Path::relative()` of output behaviour.
14-
- Affected `Path::UrlToPath()` of output behaviour.
15-
- Affected `Path::toNamespcedPath()` of output behaviour.
16-
- Added `Path::toNamespcedPath()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
17-
- Added `Path::removeExt()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
18-
- Added `Path::hasExt()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
19-
- Added `Path::changeExt()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
20-
- Added `Path::localBase()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
21-
22-
## [9.2.0](https://github.com/lazervel/path/compare/v9.1.1...v9.2.0) - 09 November 2024
23-
- Fixed bugs `Path::tmp()` that caused [e.g., incorrect output], changes output behaviour. see [CHANGELOG](https://github.com/lazervel/path/compare/v9.1.1...v9.2.0)
24-
25-
## [9.1.0](https://github.com/lazervel/path/compare/v9.0.0...v9.1.0) - 08 November 2024
26-
- Added `Path::apply()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
27-
- Added `Path::real()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
28-
- Removed Temporarily `Path::callMap()` This method has been temporarily removed due to performance issues. It will be reintroduced in a future version (v9.3.0) after optimizations are completed.
29-
- Fixed bugs `Path::canonicalize()` that caused [e.g., incorrect output].
30-
- Fixed bugs `Path::isLocal()` that caused [e.g., incorrect output].
31-
- Fixed bugs `Path::rootname()` that caused [e.g., incorrect output].
32-
33-
## [9.0.0](https://github.com/lazervel/path/compare/v8.2.2...v9.0.0) - 08 November 2024
34-
- [BC BREAK] Since v8.x, Due to significant updates in the library, all previous configurations may no longer work as expected. Users will need to reconfigure their settings to align with the new structure and behavior introduced in this update.
35-
- Review the updated documentation for `Path` to understand the new behavior.
36-
- Ensure that any calls to these methods are updated to accommodate these changes.
37-
- Affected `Path::canonicalize()` of output behaviour.
38-
- Affected `Path::resolve()` of output behaviour.
39-
- Affected `Path::normalize()` of output behaviour.
40-
- Affected `Path::optimize()` of output behaviour.
41-
- Affected `Path::join()` of output behaviour.
42-
- Affected `Path::relative()` of output behaviour.
43-
- Affected `Path::UrlToPath()` of output behaviour.
44-
- Affected `Path::toNamespcedPath()` of output behaviour.
45-
- Added `Path::toNamespcedPath()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
46-
47-
## [8.2.0](https://github.com/lazervel/path/releases/tag/v8.2.0) - 04 November 2024
48-
- Added `Path::pathToURL()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
49-
- Added `Path::UrlToPath()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
50-
51-
## [8.1.0](https://github.com/lazervel/path/releases/tag/v8.1.0) - 02 November 2024
52-
- Added `Path::callMap()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
53-
- Added `Path::checkLength()` method in PHP `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
54-
55-
## [8.0.1](https://github.com/lazervel/path/releases/tag/v8.0.1) - 01 November 2024
56-
- Fixed error handling for method calls to prevent unexpected runtime errors of `Path::extname()`, `Path::filename()` and `Path::info()`.
57-
- Enhanced validation checks to ensure proper usage of properties and methods, reducing the likelihood of errors.
58-
59-
## [8.0.0](https://github.com/lazervel/path/compare/v7.3.0...v8.0.0) - 01 November 2024
60-
- [BC BREAK] Since v8.x, Due to significant updates in the library, all previous configurations may no longer work as expected. Users will need to reconfigure their settings to align with the new structure and behavior introduced in this update.
61-
- Review the updated documentation for `Path::resolve()`, `Path::normalize()`, `Path::join()`, and `Path::optimize()` and `Path::relative()` to understand the new behavior.
62-
- Ensure that any calls to these methods are updated to accommodate these changes.
63-
64-
## [7.3.0](https://github.com/lazervel/path/releases/tag/v7.3.0) - 31 October 2024
65-
- Added `Path::canonicalize()` method in `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
66-
- Added `Path::optimize()` method in `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
67-
68-
## [7.2.0](https://github.com/lazervel/path/releases/tag/v7.2.0) - 30 October 2024
69-
- Added `Path::isAbsolute()` method in `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
70-
- Added `Path::isLocal()` method in `path` develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
71-
72-
## [7.1.0](https://github.com/lazervel/path/releases/tag/v7.1.0) - 30 October 2024
73-
- Added `Path::info()` method to get information about a file path, develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
74-
- Added `Path::basename()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
75-
- Added `Path::extname()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
76-
- Added `Path::filename()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
77-
- Added `Path::tmp()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
78-
- Added `Path::format()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
79-
- Added `Path::parse()` method develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
80-
81-
## [7.0.0](https://github.com/lazervel/path/releases/tag/v7.0.0) - 29 October 2024
82-
- Removed `Path::separate()` method that is no longer available.
83-
- Removed `Path::real()` method that is no longer available.
84-
- Renamed method `Path::filePaths()` to `Path::combine()` for clarity and consistency.
85-
- Fixed bugs in method `Path::combine` that caused [e.g., incorrect output, duplicate combination, etc.].
86-
87-
## [6.0.0](https://github.com/lazervel/path/releases/tag/v6.0.0) - 29 October 2024
88-
- Added new feature `Path::win32` property for `win32` (Windows) platform, develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
89-
- Added new feature `Path::posix` property for `posix` (Linux/macOs) platform, develope by [@shahzadamodassir](https://github.com/shahzadamodassir).
90-
91-
**Suggest:** We allow to use PHP `path` library version from [7.0.0](https://github.com/lazervel/path/releases/tag/v7.0.0) to [latest](https://github.com/lazervel/path/releases/latest) Recomended [latest](https://github.com/lazervel/path/releases/latest) version for best performance.
2+
## [Unreleased](https://github.com/lazervel/path/releases/v1.0.0)

README.md

+67-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PHP Path Help with handling or manipulating file and directory path.
1212
<a href="https://github.com/lazervel/path/releases"><img src="https://img.shields.io/github/release/lazervel/path.svg?style=flat-square" alt="Latest Version"></img></a>
1313
</p>
1414

15-
## Installation
15+
## Composer Installation
1616

1717
Installation is super-easy via [Composer](https://getcomposer.org)
1818

@@ -24,7 +24,6 @@ or add it by hand to your `composer.json` file.
2424

2525
## The Features of PHP Path
2626
- [Path::basename($path[, $suffix])](#pathbasenamepath-suffix)
27-
- [Path::callMap($method, $args)](#pathcallmapmethod-args)
2827
- [Path::canonicalize($path)](#pathcanonicalizepath)
2928
- [Path::changeExt($path, $newExt)]()
3029
- [Path::combine($paths, $names)](#pathcombinepaths-names)
@@ -85,11 +84,6 @@ Path::basename('/home/local/user/example.html', '.html');
8584
// Returns: 'example'
8685
```
8786

88-
## Path::callMap($method, $args)
89-
```php
90-
// Temporary Unavailable
91-
```
92-
9387
## Path::canonicalize($path)
9488

9589
For example, on POSIX:
@@ -188,7 +182,22 @@ explode(Path::delimiter, getenv('PATH'));
188182
```
189183

190184
## Path::dirname($path[, $suffix, $levels])
185+
186+
For example, on POSIX:
187+
191188
```php
189+
Path::dirname('/foo/bar/baz/asdf/quux\\abcd\\xyz');
190+
// Returns: '/foo/bar/baz/asdf'
191+
```
192+
193+
On Windows:
194+
195+
```php
196+
Path::dirname('/foo/bar/baz/asdf/quux');
197+
// Returns: '/foo/bar/baz/asdf'
198+
199+
Path::dirname('/foo/bar/baz/asdf/quux\\abcd\\xyz');
200+
// Returns: '/foo/bar/baz/asdf/quux\abcd'
192201
```
193202

194203
## Path::extname($path)
@@ -422,7 +431,53 @@ Path::win32::normalize('C:////temp\\\\/\\/\\/foo/bar');
422431
```
423432

424433
## Path::parse($path)
434+
435+
For example, on POSIX:
436+
425437
```php
438+
Path::parse('/home/user/dir/file.txt');
439+
// Returns:
440+
// [
441+
// 'root' => '/',
442+
// 'dir' => '/home/user/dir',
443+
// 'base' => 'file.txt',
444+
// 'ext' => '.txt',
445+
// 'name' => 'file'
446+
// ]
447+
```
448+
449+
```
450+
┌─────────────────────┬────────────┐
451+
│ dir │ base │
452+
├──────┬ ├──────┬─────┤
453+
│ root │ │ name │ ext │
454+
" / home/user/dir / file .txt "
455+
└──────┴──────────────┴──────┴─────┘
456+
(All spaces in the "" line should be ignored. They are purely for formatting.)
457+
```
458+
459+
On Windows:
460+
461+
```php
462+
path.parse('C:\\path\\dir\\file.txt');
463+
// Returns:
464+
// [
465+
// 'root' => 'C:\\',
466+
// 'dir' => 'C:\\path\\dir',
467+
// 'base' => 'file.txt',
468+
// 'ext' => '.txt',
469+
// 'name' => 'file'
470+
// ]
471+
```
472+
473+
```
474+
┌─────────────────────┬────────────┐
475+
│ dir │ base │
476+
├──────┬ ├──────┬─────┤
477+
│ root │ │ name │ ext │
478+
" C:\ path\dir \ file .txt "
479+
└──────┴──────────────┴──────┴─────┘
480+
(All spaces in the "" line should be ignored. They are purely for formatting.)
426481
```
427482

428483
## Path::pathname($path)
@@ -662,6 +717,11 @@ Path::tmp('foot\\bar\\baz');
662717

663718
## Path::toNamespacedPath($path)
664719
```php
720+
Path::toNamespacedPath('\\foo\\bar/baz\\asdfquux\\abcd\\xyz');
721+
// Returns: '\\\\?\\G:\\foo\\bar\\baz\\asdfquux\\abcd\\xyz'
722+
723+
Path::toNamespacedPath('//foo\\bar/baz\\asdfquux\\abcd\\xyz');
724+
// Returns: '\\\\?\\UNC\\foo\\bar\\baz\\asdfquux\\abcd\\xyz'
665725
```
666726

667727
## Path::UrlToPath($url)

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "library",
55
"keywords": ["path", "filesys", "fs", "filesystem"],
66
"license": "MIT",
7+
"homepage": "https://github.com/lazervel",
78
"autoload": {
89
"psr-4": {
910
"Path\\": "src/"
@@ -16,7 +17,7 @@
1617
"authors": [
1718
{
1819
"name": "Shahzada Modassir",
19-
"email": "codingmodassir@gmail.com",
20+
"email": "shahzadamodassir@gmail.com",
2021
"homepage": "https://github.com/shahzadamodassir"
2122
}
2223
],

0 commit comments

Comments
 (0)