Local development without a webserver
Is it possible to create a Satis repository on a local filesystem that is accessible to projects on the same filesystem, without a webserver or HTTP? I'm finding that this line in satis.json produces the error homepage : Invalid URL format:
"homepage": "file:///mnt/daladi/dev/tests/php-composer/composer-test-repo/"
I am honestly not sure. Since Satis sort of functions as a Packagist alternative, I think composer also expects it to be web accessible? It's not really like a git repository for a single package which can be accessed locally. @stof Or am I wrong; do you perhaps have better insight into this?
Hmm a quick peek at the Composer repository class would suggest I am wrong indeed;
https://github.com/composer/composer/blob/main/src/Composer/Repository/ComposerRepository.php#L144
Just out of curiosity, have you tried file:// instead of file:/// ?
The issue is that the JSON schema requires homepage to be a URL.
Looking at the regex used by the PHP library used by composer to validate the uri format, it does not seem to accept URIs with an empty host name: https://github.com/jsonrainbow/json-schema/blob/3c25fe750c1599716ef26aa997f7c026cee8c4b7/src/JsonSchema/Tool/Validator/UriValidator.php#L11-L20
And that is the case for a file URL.
Agreed, in other words the URI validator doesn't support URLs with the file:// scheme. It could be easily fixed by adding a ? after the hostname group in the regexp, making it optional. I'm not sure if this is a bug as such, or a deliberate design decision. Even if this was changed, I don't know if the rest of the software would support local filesystem access.
Just out of curiosity, have you tried
file://instead offile:///?
It looks like this would result in the validation passing, but it would be a hack since strictly there should be the 3 slashes - the third slash being the start of the filesystem path
Oh boy https://en.wikipedia.org/wiki/File_URI_scheme
Honestly not sure if this should be considered a "bug" in the library used; or if this warrants a different approach to validating the homepage value.
https://github.com/jsonrainbow/json-schema/pull/858 I think this resolves the issue described here; so I think we can close this issue if it gets merged, released and picked up by composer/composer.