okapi/path

PHP Path is a PHP library that provides utilities for handling file paths.

1.0.0 2023-02-17 23:19 UTC

This package is auto-updated.

Last update: 2024-12-18 16:02:08 UTC


README

PHP Path

License: MIT Twitter: @WalterWoshid PHP: >=8.0 Packagist Build

Coverage - PHP 8.0 Coverage - PHP 8.1 Coverage - PHP 8.2

PHP Path is a PHP library that provides utilities for handling file paths.

It is based on Node.js's path module.

Installation

composer require okapi/path

Usage

<?php

use Okapi\Path\Path;

// Resolve

$path = Path::resolve('./path/to/file.txt');
// --> /project/path/to/file.txt

$path = Path::resolve([
    './path/to/file.txt',
    '../project2/file.txt',
]);
// [0] --> /project/path/to/file.txt
// [1] --> /project2/file.txt



// Join

$path = Path::join('/project', 'path', 'to', 'file.txt');
// --> /project/path/to/file.txt

Testing

  • Run composer run-script test
    or
  • Run composer run-script test-coverage

Show your support

Give a ⭐ if this project helped you!

📝 License

Copyright © 2023 Valentin Wotschel.
This project is MIT licensed.