Skip to content

Please add $config->path($url) and $config->url($path) to API #326

@BernhardBaumrock

Description

@BernhardBaumrock

Short description of the issue

I find myself very often converting paths to urls and vice versa. For example today I had to deal with it when using MPDF library and file field items.

Expected behavior

It would be great to have an easy and fool proof solution to convert relative urls to paths and paths to relative urls.

Actual behavior

At the moment we need to do complicated string concatenations that are even error prone (for example when one does not think of different directory separators on different platforms or installations in subfolders). See my related PR here: processwire/processwire#143

Examples of possible API implementation

$url = $pages->get(123)->mypdf->url;
// eg /site/assets/files/123/myfile.pdf

$path = $config->path($url);
// eg /var/www/mysite/site/assets/files/123/myfile.pdf

$url = $config->url($path);
// again /site/assets...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions