{"id":22104684,"url":"https://github.com/riimu/kit-pathjoin","last_synced_at":"2025-07-25T02:31:37.798Z","repository":{"id":24321003,"uuid":"27717475","full_name":"Riimu/Kit-PathJoin","owner":"Riimu","description":"Cross-platform library for normalizing and joining file system paths","archived":false,"fork":false,"pushed_at":"2017-07-15T13:35:34.000Z","size":36,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-18T09:56:27.699Z","etag":null,"topics":["file-path","filesystem","php","php-library"],"latest_commit_sha":null,"homepage":"http://kit.riimu.net","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Riimu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-08T14:01:50.000Z","updated_at":"2022-07-11T03:49:43.000Z","dependencies_parsed_at":"2022-07-11T06:00:32.718Z","dependency_job_id":null,"html_url":"https://github.com/Riimu/Kit-PathJoin","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riimu%2FKit-PathJoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riimu%2FKit-PathJoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riimu%2FKit-PathJoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riimu%2FKit-PathJoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Riimu","download_url":"https://codeload.github.com/Riimu/Kit-PathJoin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227501358,"owners_count":17781412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-path","filesystem","php","php-library"],"created_at":"2024-12-01T06:34:09.759Z","updated_at":"2024-12-01T06:34:10.542Z","avatar_url":"https://github.com/Riimu.png","language":"PHP","readme":"# Path joiner and normalizer #\n\n*PathJoin* is PHP library for normalizing and joining file system paths. The\npurpose of this library is to make easier to work with file system paths\nirregardless of the platform and the system directory separator.\n\nThe purpose of file path normalization is to provide a single consistent file\npath representation. In other words, the normalization in this library will\nresolve `.` and `..` directory references and also condense multiple directory\nseparators into one. This makes it much easier to avoid common problems when\ncomparing paths against each other.\n\nWhile PHP provides a built in function `realpath()`, it is not usable in every\ncase since it works by using the file system. This library simply combines and\nnormalizes the paths using string handling. There is no requirement for the\nfiles or directories to be readable or even exist.\n\nThe API documentation is available at: http://kit.riimu.net/api/pathjoin/\n\n[![Travis](https://img.shields.io/travis/Riimu/Kit-PathJoin.svg?style=flat-square)](https://travis-ci.org/Riimu/Kit-PathJoin)\n[![Scrutinizer](https://img.shields.io/scrutinizer/g/Riimu/Kit-PathJoin.svg?style=flat-square)](https://scrutinizer-ci.com/g/Riimu/Kit-PathJoin/)\n[![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/Riimu/Kit-PathJoin.svg?style=flat-square)](https://scrutinizer-ci.com/g/Riimu/Kit-PathJoin/)\n[![Packagist](https://img.shields.io/packagist/v/riimu/kit-pathjoin.svg?style=flat-square)](https://packagist.org/packages/riimu/kit-pathjoin)\n\n## Requirements ##\n\n  * The minimum supported PHP version is 5.6\n\n## Installation ##\n\n### Installation with Composer ###\n\nThe easiest way to install this library is to use Composer to handle your\ndependencies. In order to install this library via Composer, simply follow\nthese two steps:\n\n  1. Acquire the `composer.phar` by running the Composer\n     [Command-line installation](https://getcomposer.org/download/)\n     in your project root.\n\n  2. Once you have run the installation script, you should have the `composer.phar`\n     file in you project root and you can run the following command:\n\n     ```\n     php composer.phar require \"riimu/kit-pathjoin:^1.2\"\n     ```\n\nAfter installing this library via Composer, you can load the library by\nincluding the `vendor/autoload.php` file that was generated by Composer during\nthe installation.\n\n### Adding the library as a dependency ###\n\nIf you are already familiar with how to use Composer, you may alternatively add\nthe library as a dependency by adding the following `composer.json` file to your\nproject and running the `composer install` command:\n\n```json\n{\n    \"require\": {\n        \"riimu/kit-pathjoin\": \"^1.2\"\n    }\n}\n```\n\n### Manual installation ###\n\nIf you do not wish to use Composer to load the library, you may also download\nthe library manually by downloading the [latest release](https://github.com/Riimu/Kit-PathJoin/releases/latest)\nand extracting the `src` folder to your project. You may then include the\nprovided `src/autoload.php` file to load the library classes.\n\n## Usage ##\n\nThis library provides two convenient methods, `Path::normalize()` and\n`Path::join()`. Both of these methods work in a very similar fashion. The main\ndifference is that while the `join()` method can accept multiple paths to join,\nthe `normalize()` will only accept a single path. Both of the methods will\nreturn a normalized path as the result.\n\nThe following example will contain numerous different use cases of the library:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\nuse Riimu\\Kit\\PathJoin\\Path;\n\n// Both of the following will output 'foo/bar' on Unix and 'foo\\bar' on Windows\necho Path::normalize('foo/bar') . PHP_EOL;\necho Path::join('foo', 'bar') . PHP_EOL;\n\n// The join method accepts multiple arguments or a single array\necho Path::join('foo', 'bar', 'baz') . PHP_EOL;   // outputs 'foo/bar/baz'\necho Path::join(['foo', 'bar', 'baz']) . PHP_EOL; // outputs 'foo/bar/baz'\n\n// The '.' and '..' directory references will be resolved in the paths\necho Path::normalize('foo/./bar/../baz') . PHP_EOL;     // outputs 'foo/baz'\necho Path::join(['foo/./', 'bar', '../baz']) . PHP_EOL; // outputs 'foo/baz'\n\n// Only the first path can denote an absolute path in the join method\necho Path::join('/foo', '/bar/baz') . PHP_EOL;     // outputs '/foo/bar/baz'\necho Path::join('foo', '/bar') . PHP_EOL;          // outputs 'foo/bar'\necho Path::join('foo', '../bar', 'baz') . PHP_EOL; // outputs 'bar/baz'\necho Path::join('', '/bar', 'baz') . PHP_EOL;      // outputs 'bar/baz'\n\n// Relative paths can start with a '..', but absolute paths cannot\necho Path::join('/foo', '../../bar', 'baz') . PHP_EOL; // outputs '/bar/baz'\necho Path::join('foo', '../../bar', 'baz') . PHP_EOL;  // outputs '../bar/baz'\n\n// Empty paths will result in a '.'\necho Path::normalize('foo/..') . PHP_EOL;\necho Path::join('foo', 'bar', '../..') . PHP_EOL;\n```\n\nThe `Path::normalize()` also accepts a second parameter `$prependDrive` that\ntakes a boolean value and defaults to true. On Windows platforms, the drive\nletter is important part of the absolute path. Thus, when the parameter is set\nto true, the method will prepend the drive letter of the current working\ndirectory to absolute paths if the absolute path does not provide one itself.\n\nThe following example is true for Windows systems, if the working directory is\nlocated on the C: drive:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\nuse Riimu\\Kit\\PathJoin\\Path;\n\necho Path::normalize('/foo/bar') . PHP_EOL;        // outputs 'C:\\foo\\Bar'\necho Path::normalize('D:/foo/bar') . PHP_EOL;      // outputs 'D:\\foo\\Bar'\necho Path::normalize('/foo/bar', false) . PHP_EOL; // outputs '\\foo\\Bar'\n```\n\n## Credits ##\n\nThis library is Copyright (c) 2014-2017 Riikka Kalliomäki.\n\nSee LICENSE for license and copying information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friimu%2Fkit-pathjoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friimu%2Fkit-pathjoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friimu%2Fkit-pathjoin/lists"}