thephpleague/flysystem · error · InvalidArgumentException
At least one prefix is required.
Error message
At least one prefix is required.
What it means
Error "At least one prefix is required." thrown in thephpleague/flysystem.
Source
Thrown at src/UrlGeneration/ShardedPrefixPublicUrlGenerator.php:27
use function array_map;
use function count;
use function crc32;
final class ShardedPrefixPublicUrlGenerator implements PublicUrlGenerator
{
/** @var PathPrefixer[] */
private array $prefixes;
private int $count;
/**
* @param string[] $prefixes
*/
public function __construct(array $prefixes)
{
$this->count = count($prefixes);
if ($this->count === 0) {
throw new InvalidArgumentException('At least one prefix is required.');
}
$this->prefixes = array_map(static fn (string $prefix) => new PathPrefixer($prefix, '/'), $prefixes);
}
public function publicUrl(string $path, Config $config): string
{
$index = abs(crc32($path)) % $this->count;
return $this->prefixes[$index]->prefixPath($path);
}
}
View on GitHub (pinned to b277b5dc3d)
When it happens
Trigger: Thrown at src/UrlGeneration/ShardedPrefixPublicUrlGenerator.php:27 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thephpleague/flysystem@b277b5dc3d (2026-08-17).
Data as JSON: /api/errors/4809d9b10f04b38f.
Report an issue: GitHub.