{"id":16409531,"url":"https://github.com/pointybeard/helpers-functions-paths","last_synced_at":"2025-07-06T01:05:18.077Z","repository":{"id":57043213,"uuid":"187543936","full_name":"pointybeard/helpers-functions-paths","owner":"pointybeard","description":"A collection of helpful functions related to paths, directories, and files names","archived":false,"fork":false,"pushed_at":"2020-11-10T13:13:34.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T15:51:17.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pointybeard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-20T00:43:10.000Z","updated_at":"2020-11-10T13:13:31.000Z","dependencies_parsed_at":"2022-08-23T23:40:29.936Z","dependency_job_id":null,"html_url":"https://github.com/pointybeard/helpers-functions-paths","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pointybeard/helpers-functions-paths","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-paths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-paths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-paths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-paths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pointybeard","download_url":"https://codeload.github.com/pointybeard/helpers-functions-paths/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-paths/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263833416,"owners_count":23517373,"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":[],"created_at":"2024-10-11T06:20:18.484Z","updated_at":"2025-07-06T01:05:18.010Z","avatar_url":"https://github.com/pointybeard.png","language":"PHP","readme":"# PHP Helpers: Path Functions\n\nA collection of helpful functions related to paths, directories, and files names\n\n## Installation\n\nThis library is installed via [Composer](http://getcomposer.org/). To install, use `composer require pointybeard/helpers-functions-paths` or add `\"pointybeard/helpers-functions-paths\": \"~1.0\"` to your `composer.json` file.\n\nAnd run composer to update your dependencies:\n\n    $ curl -s http://getcomposer.org/installer | php\n    $ php composer.phar update\n\n### Requirements\n\nThere are no particuar requirements for this library other than PHP 7.4 or greater.\n\nTo include all the [PHP Helpers](https://github.com/pointybeard/helpers) packages on your project, use `composer require pointybeard/helpers` or add `\"pointybeard/helpers\": \"~1.0\"` to your composer file.\n\n## Usage\n\nThis library is a collection of helpful functions related to paths, directories, and files names. They are included by the vendor autoloader automatically. The functions have a namespace of `pointybeard\\Helpers\\Functions\\Paths`\n\nThe following functions are provided:\n\n-   `is_path_absolute(string $path) : bool`\n-   `get_relative_path(string $from, string $to, bool $strict = true): string`\n\nExample usage:\n\n```php\n\u003c?php\n\ninclude __DIR__ . '/vendor/autoload.php';\n\nuse pointybeard\\Helpers\\Functions\\Paths;\n\nvar_dump(Paths\\is_path_absolute('/etc/apache2/sites-enabled/mysite.conf'));\n// bool(true)\n\nvar_dump(Paths\\is_path_absolute(getcwd() . '/../../potato.json'));\n// bool(false)\n\nvar_dump(Paths\\is_path_absolute('./potato.json'));\n// bool(false)\n\nvar_dump(Paths\\is_path_absolute('/var/www/mysite/assets/json/../json/potato.json'));\n// bool(false)\n\nvar_dump(Paths\\get_relative_path(getcwd(), getcwd()));\n// string(1) \".\"\n\nvar_dump(Paths\\get_relative_path(\"/var/www/banana/\", \"/etc/logs/blah\", false));\n// string(22) \"../../../etc/logs/blah\"\n\nvar_dump(Paths\\get_relative_path(getcwd(), getcwd() . '/some/sub/folder/path'));\n// string(22) \"./some/sub/folder/path\"\n\nvar_dump(Paths\\get_relative_path('/var/www/mysite', '/var/www/someothersite'));\n// string(16) \"../someothersite\"\n\nvar_dump(Paths\\get_relative_path('/var/www/mysite/docs/index/files', '/var/www/someothersite/docs/index/files'));\n// string(42) \"../../../../someothersite/docs/index/files\"\n\nvar_dump(Paths\\get_relative_path('/var/www/mywebsite.com/lib/extensions/template/data-sources', '/var/www/mywebsite.com/lib/extensions/template/src/Includes/datasource'));\n// string(26) \"../src/Includes/datasource\"\n\ntry{\n    Paths\\get_relative_path('/var/www/mysite', '../../nonexistent');\n} catch (\\Exception $ex) {\n    var_dump('ERROR! returned: ' . $ex-\u003egetMessage());\n}\n// string(119) \"ERROR! returned: path ../../nonexistent is relative and does not exist! Make sure path exists (or set $strict to false)\"\n\n/** Same thing again, but this time with strict checking turned off **/\ntry{\n    Paths\\get_relative_path('/var/www/mysite', '../../nonexistent', false);\n} catch (\\Exception $ex) {\n    var_dump('ERROR! returned: ' . $ex-\u003egetMessage());\n}\n// string(84) \"ERROR! returned: Both $from and $to paths must be absolute when $strict is disabled!\"\n\n```\n\n## Support\n\nIf you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-paths/issues),\nor better yet, fork the library and submit a pull request.\n\n## Contributing\n\nWe encourage you to contribute to this project. Please check out the [Contributing documentation](https://github.com/pointybeard/helpers-functions-paths/blob/master/CONTRIBUTING.md) for guidelines about how to get involved.\n\n## Author\n-   Alannah Kearney - https://github.com/pointybeard\n-   See also the list of [contributors][ext-contributor] who participated in this project\n\n## License\n\n\"PHP Helpers: Path Functions\" is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n\n[ext-contributor]: https://github.com/pointybeard-boilerplate/symext-template-extension/contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpointybeard%2Fhelpers-functions-paths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpointybeard%2Fhelpers-functions-paths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpointybeard%2Fhelpers-functions-paths/lists"}